From d3ee1d94574e28ed3b84fbed7ff5a065bec009be Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 14 Dec 2023 20:09:31 -0800 Subject: [PATCH] Various help fixes. Ensure that the usage lines include everything mentioned below in the detailed help, and vice versa. Plus a couple of clarifications (like what's the offset for fallocate, and the fact that the length is mandatory). For the ones I've touched, I've improved the consistency of alphabetization, but I haven't alphabetized the ones I had no other reason to touch. --- toys/lsb/gzip.c | 2 +- toys/lsb/mktemp.c | 2 +- toys/net/httpd.c | 2 +- toys/net/netcat.c | 6 +++--- toys/other/factor.c | 2 +- toys/other/fallocate.c | 7 +++++-- toys/other/hexedit.c | 2 +- toys/other/readlink.c | 2 +- toys/other/sha3sum.c | 2 +- toys/other/timeout.c | 2 +- toys/other/watch.c | 2 +- toys/posix/cal.c | 2 +- toys/posix/cksum.c | 6 +++--- toys/posix/cp.c | 6 +++--- toys/posix/cpio.c | 2 +- toys/posix/df.c | 10 +++++----- toys/posix/du.c | 10 +++++----- toys/posix/echo.c | 4 ++-- toys/posix/env.c | 2 +- toys/posix/fold.c | 2 +- toys/posix/grep.c | 2 +- toys/posix/head.c | 2 +- toys/posix/id.c | 2 +- toys/posix/ln.c | 4 ++-- toys/posix/nice.c | 2 ++ toys/posix/patch.c | 2 +- toys/posix/renice.c | 9 ++++++--- toys/posix/sort.c | 11 ++++++----- toys/posix/test.c | 2 +- toys/posix/uname.c | 5 +++-- toys/posix/wc.c | 2 +- toys/posix/xargs.c | 4 ++-- 32 files changed, 66 insertions(+), 56 deletions(-) diff --git a/toys/lsb/gzip.c b/toys/lsb/gzip.c index 691f9b75..813da4ff 100644 --- a/toys/lsb/gzip.c +++ b/toys/lsb/gzip.c @@ -48,7 +48,7 @@ config ZCAT bool "zcat" default y help - usage: zcat [FILE...] + usage: zcat [-f] [FILE...] Decompress files to stdout. Like `gzip -dc`. diff --git a/toys/lsb/mktemp.c b/toys/lsb/mktemp.c index 530a4a26..a84c1a03 100644 --- a/toys/lsb/mktemp.c +++ b/toys/lsb/mktemp.c @@ -10,7 +10,7 @@ config MKTEMP bool "mktemp" default y help - usage: mktemp [-dqu] [-p DIR] [TEMPLATE] + usage: mktemp [-dqtu] [-p DIR] [TEMPLATE] Safely create a new file "DIR/TEMPLATE" and print its name. diff --git a/toys/net/httpd.c b/toys/net/httpd.c index 845175dd..d649b78d 100644 --- a/toys/net/httpd.c +++ b/toys/net/httpd.c @@ -18,7 +18,7 @@ config HTTPD bool "httpd" default y help - usage: httpd [-e STR] [DIR] + usage: httpd [-de STR] [-v] [DIR] Serve contents of directory as static web pages. diff --git a/toys/net/netcat.c b/toys/net/netcat.c index 38348949..3783b821 100644 --- a/toys/net/netcat.c +++ b/toys/net/netcat.c @@ -11,7 +11,7 @@ config NETCAT bool "netcat" default y help - usage: netcat [-46ElLtUu] [-wpq #] [-s addr] {IPADDR PORTNUM|-f FILENAME|COMMAND...} + usage: netcat [-46ELlntUu] [-pqWw #] [-s addr] {IPADDR PORTNUM|-f FILENAME|COMMAND...} Forward stdin/stdout to a file or network connection. @@ -19,8 +19,8 @@ config NETCAT -6 Force IPv6 -E Forward stderr -f Use FILENAME (ala /dev/ttyS0) instead of network - -l Listen for one incoming connection, then exit -L Listen and background each incoming connection (server mode) + -l Listen for one incoming connection, then exit -n No DNS lookup -p Local port number -q Quit SECONDS after EOF on stdin, even if stdout hasn't closed yet @@ -28,8 +28,8 @@ config NETCAT -t Allocate tty -u Use UDP -U Use a UNIX domain socket - -w SECONDS timeout to establish connection -W SECONDS timeout for more data on an idle connection + -w SECONDS timeout to establish connection When listening the COMMAND line is executed as a child process to handle an incoming connection. With no COMMAND -l forwards the connection diff --git a/toys/other/factor.c b/toys/other/factor.c index 4e893a07..ed67ab88 100644 --- a/toys/other/factor.c +++ b/toys/other/factor.c @@ -12,7 +12,7 @@ config FACTOR bool "factor" default y help - usage: factor NUMBER... + usage: factor [-hx] NUMBER... Factor integers. diff --git a/toys/other/fallocate.c b/toys/other/fallocate.c index b7ea940c..790ba064 100644 --- a/toys/other/fallocate.c +++ b/toys/other/fallocate.c @@ -10,9 +10,12 @@ config FALLOCATE bool "fallocate" default y help - usage: fallocate [-l size] [-o offset] file + usage: fallocate [-o OFFSET] -l SIZE FILE - Tell the filesystem to allocate space for a file. + Tell the filesystem to allocate space for a range in a file. + + -l Number of bytes in range + -o Start offset of range (default 0) */ #define FOR_fallocate diff --git a/toys/other/hexedit.c b/toys/other/hexedit.c index 3a50ed9c..4f9d6af6 100644 --- a/toys/other/hexedit.c +++ b/toys/other/hexedit.c @@ -10,7 +10,7 @@ config HEXEDIT bool "hexedit" default y help - usage: hexedit FILE + usage: hexedit [-r] FILE Hexadecimal file editor/viewer. All changes are written to disk immediately. diff --git a/toys/other/readlink.c b/toys/other/readlink.c index 7724b336..6a64eca5 100644 --- a/toys/other/readlink.c +++ b/toys/other/readlink.c @@ -9,7 +9,7 @@ config READLINK bool "readlink" default y help - usage: readlink FILE... + usage: readlink [-efmnqz] FILE... With no options, show what symlink points to, return error if not symlink. diff --git a/toys/other/sha3sum.c b/toys/other/sha3sum.c index b35c57f0..9fbb83e9 100644 --- a/toys/other/sha3sum.c +++ b/toys/other/sha3sum.c @@ -12,7 +12,7 @@ config SHA3SUM bool "sha3sum" default y help - usage: sha3sum [-S] [-a BITS] [FILE...] + usage: sha3sum [-bS] [-a BITS] [FILE...] Hash function du jour. diff --git a/toys/other/timeout.c b/toys/other/timeout.c index 553a9469..4c4288ee 100644 --- a/toys/other/timeout.c +++ b/toys/other/timeout.c @@ -10,7 +10,7 @@ config TIMEOUT bool "timeout" default y help - usage: timeout [-i] [-k DURATION] [-s SIGNAL] DURATION COMMAND... + usage: timeout [-iv] [-k DURATION] [-s SIGNAL] DURATION COMMAND... Run command line as a child process, sending child a signal if the command doesn't exit soon enough. diff --git a/toys/other/watch.c b/toys/other/watch.c index 424b0ae0..f8f3dfb1 100644 --- a/toys/other/watch.c +++ b/toys/other/watch.c @@ -12,7 +12,7 @@ config WATCH bool "watch" default y help - usage: watch [-teb] [-n SEC] PROG ARGS + usage: watch [-tebx] [-n SEC] PROG ARGS Run PROG every -n seconds, showing output. Hit q to quit. diff --git a/toys/posix/cal.c b/toys/posix/cal.c index 1d2b16aa..89a4f300 100644 --- a/toys/posix/cal.c +++ b/toys/posix/cal.c @@ -10,7 +10,7 @@ config CAL bool "cal" default y help - usage: cal [[[DAY] MONTH] YEAR] + usage: cal [-h] [[[DAY] MONTH] YEAR] Print a calendar. diff --git a/toys/posix/cksum.c b/toys/posix/cksum.c index 75fcaa1a..1662c151 100644 --- a/toys/posix/cksum.c +++ b/toys/posix/cksum.c @@ -11,15 +11,15 @@ config CKSUM bool "cksum" default y help - usage: cksum [-IPLN] [FILE...] + usage: cksum [-HIPLN] [FILE...] For each file, output crc32 checksum value, length and name of file. If no files listed, copy from stdin. Filename "-" is a synonym for stdin. -H Hexadecimal checksum (defaults to decimal) - -L Little endian (defaults to big endian) - -P Pre-inversion -I Skip post-inversion + -P Pre-inversion + -L Little endian (defaults to big endian) -N Do not include length in CRC calculation (or output) config CRC32 diff --git a/toys/posix/cp.c b/toys/posix/cp.c index 37c2afd0..4ddde8cd 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -23,7 +23,7 @@ config CP bool "cp" default y help - usage: cp [-adfHiLlnPpRrsTv] [--preserve=motcxa] [-t TARGET] SOURCE... [DEST] + usage: cp [-aDdFfHiLlnPpRrsTuv] [--preserve=motcxa] [-t TARGET] SOURCE... [DEST] Copy files from SOURCE to DEST. If more than one SOURCE, DEST must be a directory. @@ -38,14 +38,14 @@ config CP -L Follow all symlinks -l Hard link instead of copy -n No clobber (don't overwrite DEST) - -u Update (keep newest mtime) -P Do not follow symlinks -p Preserve timestamps, ownership, and mode -R Recurse into subdirectories (DEST must be a directory) -r Synonym for -R -s Symlink instead of copy - -t Copy to TARGET dir (no DEST) -T DEST always treated as file, max 2 arguments + -t Copy to TARGET dir (no DEST) + -u Update (keep newest mtime) -v Verbose Arguments to --preserve are the first letter(s) of: diff --git a/toys/posix/cpio.c b/toys/posix/cpio.c index 13fb8c58..321bbfde 100644 --- a/toys/posix/cpio.c +++ b/toys/posix/cpio.c @@ -25,7 +25,7 @@ config CPIO bool "cpio" default y help - usage: cpio -{o|t|i|p DEST} [-v] [--verbose] [-F FILE] [-R [USER][:GROUP] [--no-preserve-owner] + usage: cpio -{o|t|i|p DEST} [-dLtuv] [--verbose] [-F FILE] [-R [USER][:GROUP] [--no-preserve-owner] Copy files into and out of a "newc" format cpio archive. diff --git a/toys/posix/df.c b/toys/posix/df.c index e07b33bf..a771f4e0 100644 --- a/toys/posix/df.c +++ b/toys/posix/df.c @@ -10,19 +10,19 @@ config DF bool "df" default y help - usage: df [-HPkhi] [-t type] [FILE...] + usage: df [-aHhikP] [-t TYPE] [FILE...] The "disk free" command shows total/used/available disk space for each filesystem listed on the command line, or all currently mounted filesystems. -a Show all (including /proc and friends) - -P The SUSv3 "Pedantic" option - -k Sets units back to 1024 bytes (the default without -P) - -h Human readable (K=1024) -H Human readable (k=1000) + -h Human readable (K=1024) -i Show inodes instead of blocks - -t type Display only filesystems of this type + -k Sets units back to 1024 bytes (the default without -P) + -P The SUSv3 "Pedantic" option (512 byte blocks) + -t TYPE Display only filesystems of this type Pedantic provides a slightly less useful output format dictated by POSIX, and sets the units to 512 bytes instead of the default 1024 bytes. diff --git a/toys/posix/du.c b/toys/posix/du.c index 2e660063..0544aeee 100644 --- a/toys/posix/du.c +++ b/toys/posix/du.c @@ -14,26 +14,26 @@ config DU bool "du" default y help - usage: du [-d N] [-askxHLlmc] [FILE...] + usage: du [-d N] [-abcHKkLlmsx] [FILE...] Show disk usage, space consumed by files and directories. Size in: -b Apparent bytes (directory listing size, not space used) + -h Human readable (e.g., 1K 243M 2G) -k 1024 byte blocks (default) -K 512 byte blocks (posix) -m Megabytes - -h Human readable (e.g., 1K 243M 2G) What to show: -a All files, not just directories + -c Cumulative total + -d N Only depth < N -H Follow symlinks on cmdline -L Follow all symlinks + -l Disable hardlink filter -s Only total size of each argument -x Don't leave this filesystem - -c Cumulative total - -d N Only depth < N - -l Disable hardlink filter */ #define FOR_du diff --git a/toys/posix/echo.c b/toys/posix/echo.c index 6817ce22..702efee6 100644 --- a/toys/posix/echo.c +++ b/toys/posix/echo.c @@ -15,17 +15,17 @@ config ECHO bool "echo" default y help - usage: echo [-neE] [ARG...] + usage: echo [-Een] [ARG...] Write each argument to stdout, one space between each, followed by a newline. - -n No trailing newline -E Print escape sequences literally (default) -e Process the following escape sequences: \\ Backslash \0NNN Octal (1-3 digit) \xHH Hex (1-2 digit) \a Alert (beep/flash) \b Backspace \c Stop here (no \n) \f Form feed \n Newline \r Carriage return \t Horizontal tab \v Vertical tab + -n No trailing newline */ #define FOR_echo diff --git a/toys/posix/env.c b/toys/posix/env.c index 8e560a25..ce71a155 100644 --- a/toys/posix/env.c +++ b/toys/posix/env.c @@ -14,7 +14,7 @@ config ENV bool "env" default y help - usage: env [-i] [-u NAME] [NAME=VALUE...] [COMMAND...] + usage: env [-0i] [-u NAME] [NAME=VALUE...] [COMMAND...] Set the environment for command invocation, or list environment variables. diff --git a/toys/posix/fold.c b/toys/posix/fold.c index 27e4e685..35123ea5 100644 --- a/toys/posix/fold.c +++ b/toys/posix/fold.c @@ -10,7 +10,7 @@ config FOLD bool "fold" default y help - usage: fold [-bsSu] [-w WIDTH] [FILE...] + usage: fold [-bs] [-w WIDTH] [FILE...] Break long lines by inserting newlines. diff --git a/toys/posix/grep.c b/toys/posix/grep.c index 7309e887..6c73e5ff 100644 --- a/toys/posix/grep.c +++ b/toys/posix/grep.c @@ -15,7 +15,7 @@ config GREP bool "grep" default y help - usage: grep [-EFrivwcloqsHbhn] [-ABC NUM] [-m MAX] [-e REGEX]... [-MS PATTERN]... [-f REGFILE]... [FILE]... + usage: grep [-bcEFHhIiLlnoqrsvwZz] [-ABC NUM] [-m MAX] [-e REGEX]... [-MS PATTERN]... [-f REGFILE]... [FILE]... Show lines matching regular expressions. If no -e, first argument is regular expression to match. With no files (or "-" filename) read stdin. diff --git a/toys/posix/head.c b/toys/posix/head.c index 58da35a0..a7f19e9a 100644 --- a/toys/posix/head.c +++ b/toys/posix/head.c @@ -12,7 +12,7 @@ config HEAD bool "head" default y help - usage: head [-n NUM] [FILE...] + usage: head [-cn NUM] [-qv] [FILE...] Copy first lines from files to stdout. If no files listed, copy from stdin. Filename "-" is a synonym for stdin. diff --git a/toys/posix/id.c b/toys/posix/id.c index 6096abf5..473c6b23 100644 --- a/toys/posix/id.c +++ b/toys/posix/id.c @@ -15,7 +15,7 @@ config ID bool "id" default y help - usage: id [-nGgru] [USER...] + usage: id [-Ggnru] [USER...] Print user and group ID. diff --git a/toys/posix/ln.c b/toys/posix/ln.c index 65e1d46a..d60ad18a 100644 --- a/toys/posix/ln.c +++ b/toys/posix/ln.c @@ -10,15 +10,15 @@ config LN bool "ln" default y help - usage: ln [-sfnv] [-t DIR] [FROM...] TO + usage: ln [-fnrsTv] [-t DIR] [FROM...] TO Create a link between FROM and TO. One/two/many arguments work like "mv" or "cp". - -s Create a symbolic link -f Force the creation of the link, even if TO already exists -n Symlink at TO treated as file -r Create relative symlink from -> to + -s Create a symbolic link -t Create links in DIR -T TO always treated as file, max 2 arguments -v Verbose diff --git a/toys/posix/nice.c b/toys/posix/nice.c index 1803e611..928c0259 100644 --- a/toys/posix/nice.c +++ b/toys/posix/nice.c @@ -18,6 +18,8 @@ config NICE priority) to 19 (lowest). By default processes inherit their parent's niceness (usually 0). By default this command adds 10 to the parent's priority. Only root can set a negative niceness level. + + -n Add given adjustment to priority (default 10) */ #define FOR_nice diff --git a/toys/posix/patch.c b/toys/posix/patch.c index 6ec032bb..bc6a16fc 100644 --- a/toys/posix/patch.c +++ b/toys/posix/patch.c @@ -20,7 +20,7 @@ config PATCH bool "patch" default y help - usage: patch [-Rlsu] [-d DIR] [-i PATCH] [-p DEPTH] [-F FUZZ] [--dry-run] [FILE [PATCH]] + usage: patch [-Rlsuv] [-d DIR] [-i PATCH] [-p DEPTH] [-F FUZZ] [--dry-run] [FILE [PATCH]] Apply a unified diff to one or more files. diff --git a/toys/posix/renice.c b/toys/posix/renice.c index 4736d4ea..034a98c2 100644 --- a/toys/posix/renice.c +++ b/toys/posix/renice.c @@ -11,6 +11,10 @@ config RENICE default y help usage: renice [-gpu] -n INCREMENT ID... + + -g Group ids + -p Process ids (default) + -u User ids */ #define FOR_renice @@ -21,15 +25,14 @@ GLOBALS( ) void renice_main(void) { - int which = (toys.optflags & FLAG_g) ? PRIO_PGRP : - ((toys.optflags & FLAG_u) ? PRIO_USER : PRIO_PROCESS); + int which = FLAG(g) ? PRIO_PGRP : (FLAG(u) ? PRIO_USER : PRIO_PROCESS); char **arg; for (arg = toys.optargs; *arg; arg++) { char *s = *arg; int id = -1; - if (toys.optflags & FLAG_u) { + if (FLAG(u)) { struct passwd *p = getpwnam(s); if (p) id = p->pw_uid; } else { diff --git a/toys/posix/sort.c b/toys/posix/sort.c index 13fefef9..d69b6224 100644 --- a/toys/posix/sort.c +++ b/toys/posix/sort.c @@ -13,27 +13,28 @@ config SORT bool "sort" default y help - usage: sort [-runbcdfiMsz] [FILE...] [-k#[,#[x]] [-t X]] [-o FILE] + usage: sort [-runbCcdfiMsxVz] [FILE...] [-k#[,#[x]] [-t X]] [-o FILE] Sort all lines of text from input files (or stdin) to stdout. -r Reverse -u Unique lines only -n Numeric order (instead of alphabetical) + -b Ignore leading blanks (or trailing blanks in second part of key) -C Check whether input is sorted -c Warn if input is unsorted -d Dictionary order (use alphanumeric and whitespace chars only) -f Force uppercase (case insensitive sort) -i Ignore nonprinting characters + -k Sort by "key" (see below) -M Month sort (jan, feb, etc) - -x Hexadecimal numerical sort + -o Output to FILE instead of stdout -s Skip fallback sort (only sort with keys) - -z Zero (null) terminated lines - -k Sort by "key" (see below) -t Use a key separator other than whitespace - -o Output to FILE instead of stdout + -x Hexadecimal numerical sort -V Version numbers (name-1.234-rc6.5b.tgz) + -z Zero (null) terminated lines Sorting by key looks at a subset of the words on each line. -k2 uses the second word to the end of the line, -k2,2 looks at only the second word, diff --git a/toys/posix/test.c b/toys/posix/test.c index f9a2bbbb..881bb668 100644 --- a/toys/posix/test.c +++ b/toys/posix/test.c @@ -14,7 +14,7 @@ config TEST bool "test" default y help - usage: test [-bcdefghLPrSsuwx PATH] [-nz STRING] [-t FD] [X ?? Y] + usage: test [-bcdefghkLprSsuwx PATH] [-nz STRING] [-t FD] [X ?? Y] Return true or false by performing tests. No arguments is false, one argument is true if not empty string. diff --git a/toys/posix/uname.c b/toys/posix/uname.c index ae94577b..c89e84c3 100644 --- a/toys/posix/uname.c +++ b/toys/posix/uname.c @@ -19,7 +19,7 @@ config UNAME bool "uname" default y help - usage: uname [-asnrvm] + usage: uname [-asnrvmo] Print system information. @@ -28,8 +28,9 @@ config UNAME -r Kernel Release number -v Kernel Version -m Machine (hardware) name - -o Userspace type -a All of the above (in order) + + -o Userspace type */ #define FOR_uname diff --git a/toys/posix/wc.c b/toys/posix/wc.c index 31df00e5..0fd9b550 100644 --- a/toys/posix/wc.c +++ b/toys/posix/wc.c @@ -10,7 +10,7 @@ config WC bool "wc" default y help - usage: wc -lwcm [FILE...] + usage: wc [-lwcm] [FILE...] Count lines, words, and characters in input. diff --git a/toys/posix/xargs.c b/toys/posix/xargs.c index 67fa3a05..c5dca26a 100644 --- a/toys/posix/xargs.c +++ b/toys/posix/xargs.c @@ -15,7 +15,7 @@ config XARGS bool "xargs" default y help - usage: xargs [-0prt] [-snE STR] COMMAND... + usage: xargs [-0Pprt] [-snE STR] COMMAND... Run command line one or more times, appending arguments from stdin. @@ -25,8 +25,8 @@ config XARGS -E Stop at line matching string -n Max number of arguments per command -o Open tty for COMMAND's stdin (default /dev/null) - -p Prompt for y/n from tty before running each command -P Parallel processes (default 1) + -p Prompt for y/n from tty before running each command -r Don't run with empty input (otherwise always run command once) -s Size in bytes per command line -t Trace, print command line to stderr -- 2.39.2