ref: 5bc9b0c3cac34864d479c099283793ec4ae5565e
parent: 06ea44c895a5f97b7b9b65fce84dec2700f443fb
author: Ori Bernstein <[email protected]>
date: Tue Mar 10 06:09:34 EDT 2020
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.
--- a/rc/bin/approx
+++ b/rc/bin/approx
@@ -1,6 +1,6 @@
#!/bin/rc
if(! ~ $#* 3){
- echo usage: approx ratio min max
+ echo usage: approx ratio min max >[1=2]
exit usage
}
echo $1 $2 $3 | awk '
--- a/rc/bin/doc2txt
+++ b/rc/bin/doc2txt
@@ -3,7 +3,7 @@
rfork en
if(! ~ $#* 0 1) {
- echo 'Usage: doc2txt [file.doc]' >[1=2]
+ echo 'usage: doc2txt [file.doc]' >[1=2]
exit usage
}
--- a/rc/bin/doctype
+++ b/rc/bin/doctype
@@ -1,6 +1,11 @@
#!/bin/rc
# doctype: synthesize proper command line for troff
+if(~ $#* 0){
+ echo 'usage: doctype [ -n ] [ -T dev ] [ file ] ...' >[1=2]
+ exit usage
+}
+
troff=troff
eqn=eqn
prefer=prefer
--- a/rc/bin/juke
+++ b/rc/bin/juke
@@ -26,7 +26,7 @@
sname=$2
shift
case -*
- echo Usage: classical [-d level] [-t] [-h srvhost]
+ echo usage: juke [-d level] [-tw] [-s srv] [-h srvhost] >[1=2]
exit usage
}
shift
--- a/rc/bin/lookman
+++ b/rc/bin/lookman
@@ -16,7 +16,7 @@
*=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_. \012'} # fold case, delete funny chars
if(~ $#* 0){
- echo Usage: lookman key ... >/fd/2
+ echo usage: lookman key ... >/fd/2
exit usage
}
look $1 $index | sed 's/.* //' | sort -u >$t1
--- a/rc/bin/lp
+++ b/rc/bin/lp
@@ -93,7 +93,7 @@
argv0=lp
if(! ifs=() eval `{aux/getflags $*}) {
- echo $USAGE
+ echo $USAGE >[1=2]
exit usage
}
if(~ $flagd '?'){
--- a/rc/bin/man
+++ b/rc/bin/man
@@ -59,8 +59,8 @@
search=yes
while(~ $d 0) {
if(~ $#* 0) {
- echo 'Usage: man [-bntpPSw] [0-9] [0-9] ... name1 name2 ...' >[1=2]
- exit
+ echo 'usage: man [-bntpPSw] [0-9] [0-9] ... name1 name2 ...' >[1=2]
+ exit usage
}
if(test -d $S/$1){
sec=($sec $1)
--- a/rc/bin/psfax
+++ b/rc/bin/psfax
@@ -10,8 +10,8 @@
switch($#*){
case 0 1
- echo usage: $0 telephone-number recipient '[files]'
- exit 0
+ echo usage: $0 telephone-number recipient '[files]' >[1=2]
+ exit usage
case 2
stdin=yes
}
--- a/rc/bin/psu
+++ b/rc/bin/psu
@@ -15,6 +15,6 @@
case 1
ps $flags | sed -n '/^'$1' /p'
case *
- echo Usage: psu '[ps-flags] [ user ]' >[1=2]
+ echo usage: psu '[ps-flags] [ user ]' >[1=2]
exit usage
}
--- a/rc/bin/sig
+++ b/rc/bin/sig
@@ -5,8 +5,8 @@
*=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_ \012'} # fold case, delete funny chars
if(~ $#* 0){
- echo Usage: sig function ... >/fd/2
- exit 1
+ echo usage: sig function ... >/fd/2
+ exit usage
}
for (i) {
--- a/rc/bin/ssam
+++ b/rc/bin/ssam
@@ -4,7 +4,8 @@
flagfmt='n,e script,f sfile'
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 $*}){
usage
exit usage
--- a/rc/bin/tap
+++ b/rc/bin/tap
@@ -2,7 +2,7 @@
rfork e
if(~ $#* 0){
- echo 'Usage: ' $0 '[ pid ... ]' >[1=2]
+ echo 'usage:' $0 '[ pid ... ]' >[1=2]
exit usage
}
--- a/sys/man/1/mothra
+++ b/sys/man/1/mothra
@@ -4,7 +4,7 @@
.SH SYNOPSIS
.B mothra
[
-.B -va
+.B -dvak
]
[
.B -m
@@ -71,6 +71,9 @@
.B -v
Verbose mode. Causes HTML errors to be printed
on file-descriptor 2.
+.TP
+.B -d
+Enables debug mode.
.PP
The display contains the last message from
.I mothra,
--- a/sys/src/cmd/aan.c
+++ b/sys/src/cmd/aan.c
@@ -65,7 +65,7 @@
static 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");
}
--- a/sys/src/cmd/auth/httpauth.c
+++ b/sys/src/cmd/auth/httpauth.c
@@ -5,7 +5,7 @@
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");
}
--- a/sys/src/cmd/awk/main.c
+++ b/sys/src/cmd/awk/main.c
@@ -62,7 +62,7 @@
cmdname = argv[0];
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");
}
--- a/sys/src/cmd/bc.y
+++ b/sys/src/cmd/bc.y
@@ -956,7 +956,7 @@
sflag++;
break;
default:
- fprint(2, "Usage: bc [-cdls] [file ...]\n");
+ fprint(2, "usage: bc [-cdls] [file ...]\n");
exits("usage");
}
argc--;
--- a/sys/src/cmd/colors.c
+++ b/sys/src/cmd/colors.c
@@ -102,7 +102,7 @@
if(argc){
Usage:
- fprint(2, "Usage: %s [-rx]\n", argv0);
+ fprint(2, "usage: %s [-rx]\n", argv0);
exits("usage");
}
--- a/sys/src/cmd/compress/compress.c
+++ b/sys/src/cmd/compress/compress.c
@@ -112,9 +112,9 @@
Usage()
{
#ifdef DEBUG
- fprintf(stderr,"Usage: compress [-cdfDV] [-b maxbits] [file ...]\n");
+ fprintf(stderr,"usage: compress [-cdfDV] [-b maxbits] [file ...]\n");
#else
- fprintf(stderr,"Usage: compress [-cdfvV] [-b maxbits] [file ...]\n");
+ fprintf(stderr,"usage: compress [-cdfvV] [-b maxbits] [file ...]\n");
#endif /* DEBUG */
}
--- a/sys/src/cmd/db/main.c
+++ b/sys/src/cmd/db/main.c
@@ -93,7 +93,7 @@
sprint(b2, "/proc/%s/mem", argv[0]);
corfil = b2;
} 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");
}
if (!symfil)
--- a/sys/src/cmd/dict/canonind.awk
+++ b/sys/src/cmd/dict/canonind.awk
@@ -1,8 +1,8 @@
# turn output of mkindex into form needed by dict
BEGIN {
if(ARGC != 2) {
- print "Usage: awk -F' ' -f canonind.awk rawindex > index"
- exit 1
+ print "usage: awk -F' ' -f canonind.awk rawindex > index"
+ exit usage
}
file = ARGV[1]
ARGV[1] = ""
--- a/sys/src/cmd/dict/dict.c
+++ b/sys/src/cmd/dict/dict.c
@@ -160,7 +160,7 @@
int i;
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");
for(i = 0; dicts[i].name; i++){
a = b = "";
--- a/sys/src/cmd/getmap.c
+++ b/sys/src/cmd/getmap.c
@@ -131,7 +131,7 @@
int fd, id;
if(argc>2){
- fprint(2, "Usage: %s colormap\n", argv[0]);
+ fprint(2, "usage: %s colormap\n", argv[0]);
exits("usage");
}
map = "rgbv";
--- a/sys/src/cmd/mk/main.c
+++ b/sys/src/cmd/mk/main.c
@@ -236,7 +236,7 @@
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();
}
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -331,7 +331,7 @@
switch(argc){
default:
Usage:
- fprint(2, "Usage: %s [-dvak] [-m mtpt] [url]\n", argv0);
+ fprint(2, "usage: %s [-dvak] [-m mtpt] [url]\n", argv0);
exits("usage");
case 0:
url=getenv("url");
--- a/sys/src/cmd/ratrace.c
+++ b/sys/src/cmd/ratrace.c
@@ -156,7 +156,7 @@
void
usage(void)
{
- fprint(2, "Usage: ratrace [-c cmd [arg...]] | [pid]\n");
+ fprint(2, "usage: ratrace [-c cmd [arg...]] | [pid]\n");
threadexits("usage");
}
--- a/sys/src/cmd/sum.c
+++ b/sys/src/cmd/sum.c
@@ -10,7 +10,7 @@
void
usage(void)
{
- fprint(2, "Usage: %s [-r5] [files]\n", argv0);
+ fprint(2, "usage: %s [-5r] [file ...]\n", argv0);
exits("usage");
}
--- a/sys/src/cmd/swap.c
+++ b/sys/src/cmd/swap.c
@@ -12,7 +12,7 @@
} ARGEND;
if(argc != 1){
- fprint(2, "Usage: swap file\n");
+ fprint(2, "usage: swap file\n");
exits("usage");
}
--- a/sys/src/cmd/tcs/font/main.c
+++ b/sys/src/cmd/tcs/font/main.c
@@ -82,6 +82,6 @@
static void
usage(void)
{
- fprint(2, "Usage: %s [-s] from to\n", argv0);
+ fprint(2, "usage: %s [-s] from to\n", argv0);
exits("usage");
}
--- a/sys/src/cmd/tcs/font/merge.c
+++ b/sys/src/cmd/tcs/font/merge.c
@@ -65,7 +65,7 @@
static void
usage(void)
{
- fprint(2, "Usage: %s file ...\n", argv0);
+ fprint(2, "usage: %s file ...\n", argv0);
exits("usage");
}
--- a/sys/src/cmd/tcs/tcs.c
+++ b/sys/src/cmd/tcs/tcs.c
@@ -96,7 +96,7 @@
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;
list();
exits("usage");
--- a/sys/src/cmd/trace.c
+++ b/sys/src/cmd/trace.c
@@ -124,7 +124,7 @@
static 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);
}
--- a/sys/src/cmd/urlencode.c
+++ b/sys/src/cmd/urlencode.c
@@ -26,7 +26,7 @@
void
usage(void)
{
- fprint(2, "Usage: %s [ -d ] [ file ]\n", argv0);
+ fprint(2, "usage: %s [ -d ] [ file ]\n", argv0);
exits("usage");
}
--- a/sys/src/cmd/wc.c
+++ b/sys/src/cmd/wc.c
@@ -28,7 +28,7 @@
case 'b': pbadr++; break;
case 'c': pchar++; break;
default:
- fprint(2, "Usage: %s [-lwrbc] [file ...]\n", argv0);
+ fprint(2, "usage: %s [-lwrbc] [file ...]\n", argv0);
exits("usage");
} ARGEND
if(pline+pword+prune+pbadr+pchar == 0) {