Re: [hackers] [sbase] Cleanup usage() across sbase

From: Quentin Rameau <quinq_AT_fifth.space>
Date: Mon, 21 Dec 2015 18:36:28 +0100

Some tools didn't use argv0 for tool name, or usage() at all.
---
 chgrp.c  | 2 +-
 chown.c  | 3 ++-
 ed.c     | 5 ++---
 find.c   | 2 +-
 grep.c   | 3 ++-
 join.c   | 1 -
 nl.c     | 2 +-
 renice.c | 2 +-
 seq.c    | 4 ++--
 tar.c    | 6 ++++--
 touch.c  | 3 ++-
 which.c  | 1 -
 xargs.c  | 3 ++-
 13 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/chgrp.c b/chgrp.c
index ee5c503..299238b 100644
--- a/chgrp.c
+++ b/chgrp.c
_AT_@ -37,7 +37,7 @@ chgrp(const char *path, struct stat *st, void *data, struct recursor *r)
 static void
 usage(void)
 {
-	eprintf("usage: chgrp [-h] [-R [-H | -L | -P]] group file ...\n");
+	eprintf("usage: %s [-h] [-R [-H | -L | -P]] group file ...\n", argv0);
 }
 
 int
diff --git a/chown.c b/chown.c
index f06d541..1bf9cbb 100644
--- a/chown.c
+++ b/chown.c
_AT_@ -40,7 +40,8 @@ chownpwgr(const char *path, struct stat *st, void *data, struct recursor *r)
 static void
 usage(void)
 {
-	eprintf("usage: %s [-h] [-R [-H | -L | -P]] [owner][:[group]] file ...\n", argv0);
+	eprintf("usage: %s [-h] [-R [-H | -L | -P]] [owner][:[group]] "
+	        "file ...\n", argv0);
 }
 
 int
diff --git a/ed.c b/ed.c
index a3de436..8903957 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "arg.h"
+#include "util.h"
 
 #define REGEXSIZE  100
 #define LINESIZE    80
_AT_@ -1310,8 +1310,7 @@ doglobal(void)
 static void
 usage(void)
 {
-	fputs("ed [-s][-p][file]\n", stderr);
-	exit(1);
+	eprintf("usage: %s [-s] [-p] [file]\n", argv0);
 }
 
 static void
diff --git a/find.c b/find.c
index 72926e1..ad0c731 100644
--- a/find.c
+++ b/find.c
_AT_@ -992,7 +992,7 @@ find(char *path, struct findhist *hist)
 static void
 usage(void)
 {
-	eprintf("usage: %s [-H|-L] path... [expression...]\n", argv0);
+	eprintf("usage: %s [-H | -L] path ... [expression ...]\n", argv0);
 }
 
 int
diff --git a/grep.c b/grep.c
index c47e218..ca255ff 100644
--- a/grep.c
+++ b/grep.c
_AT_@ -166,7 +166,8 @@ end:
 static void
 usage(void)
 {
-	enprintf(Error, "usage: %s [-EFHchilnqsvwx] [-e pattern] [-f file] [pattern] [file ...]\n", argv0);
+	enprintf(Error, "usage: %s [-EFHchilnqsvwx] [-e pattern] [-f file] "
+	         "[pattern] [file ...]\n", argv0);
 }
 
 int
diff --git a/join.c b/join.c
index 4c68ad3..caf592f 100644
--- a/join.c
+++ b/join.c
_AT_@ -5,7 +5,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "arg.h"
 #include "text.h"
 #include "utf.h"
 #include "util.h"
diff --git a/nl.c b/nl.c
index b46932a..0e18872 100644
--- a/nl.c
+++ b/nl.c
_AT_@ -94,7 +94,7 @@ usage(void)
 {
 	eprintf("usage: %s [-p] [-b type] [-d delim] [-f type]\n"
 	        "       [-h type] [-i num] [-l num] [-n format]\n"
-		"       [-s sep] [-v num] [-w num] [file]\n", argv0);
+	        "       [-s sep] [-v num] [-w num] [file]\n", argv0);
 }
 
 static char
diff --git a/renice.c b/renice.c
index 74171b6..358c560 100644
--- a/renice.c
+++ b/renice.c
_AT_@ -37,7 +37,7 @@ renice(int which, int who, long adj)
 static void
 usage(void)
 {
-	eprintf("renice -n num [-g | -p | -u] id ...\n");
+	eprintf("usage: %s -n num [-g | -p | -u] id ...\n", argv0);
 }
 
 int
diff --git a/seq.c b/seq.c
index 46a213b..70763d1 100644
--- a/seq.c
+++ b/seq.c
_AT_@ -72,8 +72,8 @@ format:
 static void
 usage(void)
 {
-	eprintf("usage: %s [-f fmt] [-s sep] [-w] [startnum"
-		       " [step]] endnum\n", argv0);
+	eprintf("usage: %s [-f fmt] [-s sep] [-w] "
+	        "[startnum [step]] endnum\n", argv0);
 }
 
 int
diff --git a/tar.c b/tar.c
index e8dd26a..10b2e30 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -490,8 +490,10 @@ xt(int argc, char *argv[], int mode)
 static void
 usage(void)
 {
-	eprintf("usage: %s [-C dir] [-J | -Z | -a | -j | -z] -x [-m | -t] [-f file] [file ...]\n"
-		"       %s [-C dir] [-J | -Z | -a | -j | -z] [-h] -c path ... [-f file]\n", argv0, argv0);
+	eprintf("usage: %s [-C dir] [-J | -Z | -a | -j | -z] -x [-m | -t] "
+	        "[-f file] [file ...]\n"
+	        "       %s [-C dir] [-J | -Z | -a | -j | -z] [-h] -c path ... "
+	        "[-f file]\n", argv0, argv0);
 }
 
 int
diff --git a/touch.c b/touch.c
index e2dc04a..b957fa5 100644
--- a/touch.c
+++ b/touch.c
_AT_@ -111,7 +111,8 @@ parsetime(char *str, time_t current)
 static void
 usage(void)
 {
-	eprintf("usage: %s [-acm] [-d time | -r ref_file | -t time | -T time] file ...\n", argv0);
+	eprintf("usage: %s [-acm] [-d time | -r ref_file | -t time | -T time] "
+	        "file ...\n", argv0);
 }
 
 int
diff --git a/which.c b/which.c
index 352cdfa..1975710 100644
--- a/which.c
+++ b/which.c
_AT_@ -9,7 +9,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "arg.h"
 #include "util.h"
 
 static int aflag;
diff --git a/xargs.c b/xargs.c
index 242106b..0d5dd53 100644
--- a/xargs.c
+++ b/xargs.c
_AT_@ -188,7 +188,8 @@ spawn(void)
 static void
 usage(void)
 {
-	eprintf("usage: %s [-rtx] [-E eofstr] [-n num] [-s num] [cmd [arg ...]]\n", argv0);
+	eprintf("usage: %s [-rtx] [-E eofstr] [-n num] [-s num] "
+	        "[cmd [arg ...]]\n", argv0);
 }
 
 int
-- 
2.6.4
Received on Mon Dec 21 2015 - 18:36:28 CET

This archive was generated by hypermail 2.3.0 : Mon Dec 21 2015 - 18:48:12 CET