improve usage messages (thanks henesy)

Fix inconsistencies between programs and their usage
messages,  correct instances where information seems
to be missing or lost. This  includes missing arguments,
making usage consistent with manuals, and so on.
This commit is contained in:
Ori Bernstein 2020-03-10 10:09:34 -07:00
parent 06ea44c895
commit 5bc9b0c3ca
34 changed files with 47 additions and 38 deletions

View file

@ -1,6 +1,6 @@
#!/bin/rc #!/bin/rc
if(! ~ $#* 3){ if(! ~ $#* 3){
echo usage: approx ratio min max echo usage: approx ratio min max >[1=2]
exit usage exit usage
} }
echo $1 $2 $3 | awk ' echo $1 $2 $3 | awk '

View file

@ -3,7 +3,7 @@
rfork en rfork en
if(! ~ $#* 0 1) { if(! ~ $#* 0 1) {
echo 'Usage: doc2txt [file.doc]' >[1=2] echo 'usage: doc2txt [file.doc]' >[1=2]
exit usage exit usage
} }

View file

@ -1,6 +1,11 @@
#!/bin/rc #!/bin/rc
# doctype: synthesize proper command line for troff # doctype: synthesize proper command line for troff
if(~ $#* 0){
echo 'usage: doctype [ -n ] [ -T dev ] [ file ] ...' >[1=2]
exit usage
}
troff=troff troff=troff
eqn=eqn eqn=eqn
prefer=prefer prefer=prefer

View file

@ -26,7 +26,7 @@ while(! ~ $#* 0) {
sname=$2 sname=$2
shift shift
case -* case -*
echo Usage: classical [-d level] [-t] [-h srvhost] echo usage: juke [-d level] [-tw] [-s srv] [-h srvhost] >[1=2]
exit usage exit usage
} }
shift shift

View file

@ -16,7 +16,7 @@ fn sigint sighup sigterm {
*=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_. \012'} # fold case, delete funny chars *=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_. \012'} # fold case, delete funny chars
if(~ $#* 0){ if(~ $#* 0){
echo Usage: lookman key ... >/fd/2 echo usage: lookman key ... >/fd/2
exit usage exit usage
} }
look $1 $index | sed 's/.* //' | sort -u >$t1 look $1 $index | sed 's/.* //' | sort -u >$t1

View file

@ -93,7 +93,7 @@ flagfmt='D,H,L,Q,R,r,q,M mach,c copies,d printer,f font.size,i src,k jobnos,l li
argv0=lp argv0=lp
if(! ifs=() eval `{aux/getflags $*}) { if(! ifs=() eval `{aux/getflags $*}) {
echo $USAGE echo $USAGE >[1=2]
exit usage exit usage
} }
if(~ $flagd '?'){ if(~ $flagd '?'){

View file

@ -59,8 +59,8 @@ fn page {
search=yes search=yes
while(~ $d 0) { while(~ $d 0) {
if(~ $#* 0) { if(~ $#* 0) {
echo 'Usage: man [-bntpPSw] [0-9] [0-9] ... name1 name2 ...' >[1=2] echo 'usage: man [-bntpPSw] [0-9] [0-9] ... name1 name2 ...' >[1=2]
exit exit usage
} }
if(test -d $S/$1){ if(test -d $S/$1){
sec=($sec $1) sec=($sec $1)

View file

@ -10,8 +10,8 @@ case -v
switch($#*){ switch($#*){
case 0 1 case 0 1
echo usage: $0 telephone-number recipient '[files]' echo usage: $0 telephone-number recipient '[files]' >[1=2]
exit 0 exit usage
case 2 case 2
stdin=yes stdin=yes
} }

View file

@ -15,6 +15,6 @@ case 0
case 1 case 1
ps $flags | sed -n '/^'$1' /p' ps $flags | sed -n '/^'$1' /p'
case * case *
echo Usage: psu '[ps-flags] [ user ]' >[1=2] echo usage: psu '[ps-flags] [ user ]' >[1=2]
exit usage exit usage
} }

View file

@ -5,8 +5,8 @@
*=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_ \012'} # fold case, delete funny chars *=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_ \012'} # fold case, delete funny chars
if(~ $#* 0){ if(~ $#* 0){
echo Usage: sig function ... >/fd/2 echo usage: sig function ... >/fd/2
exit 1 exit usage
} }
for (i) { for (i) {

View file

@ -4,7 +4,8 @@ rfork e
flagfmt='n,e script,f sfile' flagfmt='n,e script,f sfile'
args='[ file ... ]' args='[ file ... ]'
fn usage { echo $0 '[ -n ] [ -e script ] [ -f sfile ] [ file ... ]' >[1=2] } argv0=$0
fn usage { echo usage: $argv0 '[ -n ] [ -e script ] [ -f sfile ] [ file ... ]' >[1=2] }
if(! ifs=() eval `{aux/getflags $*}){ if(! ifs=() eval `{aux/getflags $*}){
usage usage
exit usage exit usage

View file

@ -2,7 +2,7 @@
rfork e rfork e
if(~ $#* 0){ if(~ $#* 0){
echo 'Usage: ' $0 '[ pid ... ]' >[1=2] echo 'usage:' $0 '[ pid ... ]' >[1=2]
exit usage exit usage
} }

View file

@ -4,7 +4,7 @@ mothra \- retrieve and display World-Wide Web files
.SH SYNOPSIS .SH SYNOPSIS
.B mothra .B mothra
[ [
.B -va .B -dvak
] ]
[ [
.B -m .B -m
@ -71,6 +71,9 @@ The default is
.B -v .B -v
Verbose mode. Causes HTML errors to be printed Verbose mode. Causes HTML errors to be printed
on file-descriptor 2. on file-descriptor 2.
.TP
.B -d
Enables debug mode.
.PP .PP
The display contains the last message from The display contains the last message from
.I mothra, .I mothra,

View file

@ -65,7 +65,7 @@ static void timerproc(void *);
static void static void
usage(void) usage(void)
{ {
fprint(2, "Usage: %s [-cd] [-m maxto] dialstring|netdir\n", argv0); fprint(2, "usage: %s [-cd] [-m maxto] dialstring|netdir\n", argv0);
exits("usage"); exits("usage");
} }

View file

@ -5,7 +5,7 @@
void void
usage(void) usage(void)
{ {
fprint(2, "Usage:\n\t%s user pass\n\t%s authorization\n", argv0, argv0); fprint(2, "usage:\n\t%s user pass\n\t%s authorization\n", argv0, argv0);
exits("usage"); exits("usage");
} }

View file

@ -62,7 +62,7 @@ void main(int argc, char *argv[])
cmdname = argv[0]; cmdname = argv[0];
if (argc == 1) { if (argc == 1) {
Bprint(&stderr, "Usage: %s [-F fieldsep] [-mf n] [-mr n] [-v var=value] [-f programfile | 'program'] [file ...]\n", cmdname); Bprint(&stderr, "usage: %s [-F fieldsep] [-d] [-mf n] [-mr n] [-safe] [-v var=value] [-f programfile | 'program'] [file ...]\n", cmdname);
exits("usage"); exits("usage");
} }

View file

@ -956,7 +956,7 @@ main(int argc, char **argv)
sflag++; sflag++;
break; break;
default: default:
fprint(2, "Usage: bc [-cdls] [file ...]\n"); fprint(2, "usage: bc [-cdls] [file ...]\n");
exits("usage"); exits("usage");
} }
argc--; argc--;

View file

@ -102,7 +102,7 @@ main(int argc, char *argv[])
if(argc){ if(argc){
Usage: Usage:
fprint(2, "Usage: %s [-rx]\n", argv0); fprint(2, "usage: %s [-rx]\n", argv0);
exits("usage"); exits("usage");
} }

View file

@ -112,9 +112,9 @@ code_int getcode();
Usage() Usage()
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"Usage: compress [-cdfDV] [-b maxbits] [file ...]\n"); fprintf(stderr,"usage: compress [-cdfDV] [-b maxbits] [file ...]\n");
#else #else
fprintf(stderr,"Usage: compress [-cdfvV] [-b maxbits] [file ...]\n"); fprintf(stderr,"usage: compress [-cdfvV] [-b maxbits] [file ...]\n");
#endif /* DEBUG */ #endif /* DEBUG */
} }

View file

@ -93,7 +93,7 @@ main(int argc, char **argv)
sprint(b2, "/proc/%s/mem", argv[0]); sprint(b2, "/proc/%s/mem", argv[0]);
corfil = b2; corfil = b2;
} else if (argc > 0) { } else if (argc > 0) {
fprint(2, "Usage: db [-kw] [-m machine] [-I dir] [symfile] [pid]\n"); fprint(2, "usage: db [-kw] [-m machine] [-I dir] [symfile] [pid]\n");
exits("usage"); exits("usage");
} }
if (!symfil) if (!symfil)

View file

@ -1,8 +1,8 @@
# turn output of mkindex into form needed by dict # turn output of mkindex into form needed by dict
BEGIN { BEGIN {
if(ARGC != 2) { if(ARGC != 2) {
print "Usage: awk -F' ' -f canonind.awk rawindex > index" print "usage: awk -F' ' -f canonind.awk rawindex > index"
exit 1 exit usage
} }
file = ARGV[1] file = ARGV[1]
ARGV[1] = "" ARGV[1] = ""

View file

@ -160,7 +160,7 @@ usage(void)
int i; int i;
char *a, *b; char *a, *b;
Bprint(bout, "Usage: %s [-d dict] [-k] [-c cmd] [word]\n", argv0); Bprint(bout, "usage: %s [-k] [-d dict] [-c cmd] [pattern]\n", argv0);
Bprint(bout, "dictionaries (brackets mark dictionaries not present on this system):\n"); Bprint(bout, "dictionaries (brackets mark dictionaries not present on this system):\n");
for(i = 0; dicts[i].name; i++){ for(i = 0; dicts[i].name; i++){
a = b = ""; a = b = "";

View file

@ -131,7 +131,7 @@ main(int argc, char *argv[])
int fd, id; int fd, id;
if(argc>2){ if(argc>2){
fprint(2, "Usage: %s colormap\n", argv[0]); fprint(2, "usage: %s colormap\n", argv[0]);
exits("usage"); exits("usage");
} }
map = "rgbv"; map = "rgbv";

View file

@ -236,7 +236,7 @@ void
badusage(void) badusage(void)
{ {
fprint(2, "Usage: mk [-f file] [-n] [-a] [-e] [-t] [-k] [-i] [-d[egp]] [targets ...]\n"); fprint(2, "usage: mk [-f file] [-n] [-a] [-e] [-t] [-k] [-i] [-d[egp]] [targets ...]\n");
Exit(); Exit();
} }

View file

@ -331,7 +331,7 @@ void main(int argc, char *argv[]){
switch(argc){ switch(argc){
default: default:
Usage: Usage:
fprint(2, "Usage: %s [-dvak] [-m mtpt] [url]\n", argv0); fprint(2, "usage: %s [-dvak] [-m mtpt] [url]\n", argv0);
exits("usage"); exits("usage");
case 0: case 0:
url=getenv("url"); url=getenv("url");

View file

@ -156,7 +156,7 @@ writer(int lastpid)
void void
usage(void) usage(void)
{ {
fprint(2, "Usage: ratrace [-c cmd [arg...]] | [pid]\n"); fprint(2, "usage: ratrace [-c cmd [arg...]] | [pid]\n");
threadexits("usage"); threadexits("usage");
} }

View file

@ -10,7 +10,7 @@ static char exitstr[ERRMAX];
void void
usage(void) usage(void)
{ {
fprint(2, "Usage: %s [-r5] [files]\n", argv0); fprint(2, "usage: %s [-5r] [file ...]\n", argv0);
exits("usage"); exits("usage");
} }

View file

@ -12,7 +12,7 @@ main(int argc, char **argv)
} ARGEND; } ARGEND;
if(argc != 1){ if(argc != 1){
fprint(2, "Usage: swap file\n"); fprint(2, "usage: swap file\n");
exits("usage"); exits("usage");
} }

View file

@ -82,6 +82,6 @@ main(int argc, char **argv)
static void static void
usage(void) usage(void)
{ {
fprint(2, "Usage: %s [-s] from to\n", argv0); fprint(2, "usage: %s [-s] from to\n", argv0);
exits("usage"); exits("usage");
} }

View file

@ -65,7 +65,7 @@ bitblt(&screen, screen.r.min, b, b->r, S); bflush();sleep(5000);
static void static void
usage(void) usage(void)
{ {
fprint(2, "Usage: %s file ...\n", argv0); fprint(2, "usage: %s file ...\n", argv0);
exits("usage"); exits("usage");
} }

View file

@ -96,7 +96,7 @@ main(int argc, char **argv)
void void
usage(void) usage(void)
{ {
fprint(2, "Usage: %s [-slv] [-f cs] [-t cs] [file ...]\n", argv0); fprint(2, "usage: %s [-slcv] [-f ics] [-t ocs] [file ...]\n", argv0);
verbose = 1; verbose = 1;
list(); list();
exits("usage"); exits("usage");

View file

@ -124,7 +124,7 @@ char*profdev = "/proc/trace";
static void static void
usage(void) usage(void)
{ {
fprint(2, "Usage: %s [-d profdev] [-w] [-v] [-t triggerproc] [processes]\n", argv0); fprint(2, "usage: %s [-d profdev] [-w] [-v] [-t triggerproc] [pid ...]\n", argv0);
exits(nil); exits(nil);
} }

View file

@ -26,7 +26,7 @@ hexdigit(int c)
void void
usage(void) usage(void)
{ {
fprint(2, "Usage: %s [ -d ] [ file ]\n", argv0); fprint(2, "usage: %s [ -d ] [ file ]\n", argv0);
exits("usage"); exits("usage");
} }

View file

@ -28,7 +28,7 @@ main(int argc, char *argv[])
case 'b': pbadr++; break; case 'b': pbadr++; break;
case 'c': pchar++; break; case 'c': pchar++; break;
default: default:
fprint(2, "Usage: %s [-lwrbc] [file ...]\n", argv0); fprint(2, "usage: %s [-lwrbc] [file ...]\n", argv0);
exits("usage"); exits("usage");
} ARGEND } ARGEND
if(pline+pword+prune+pbadr+pchar == 0) { if(pline+pword+prune+pbadr+pchar == 0) {