diff options
author | Jim Meyering <jim@meyering.net> | 1993-04-04 14:41:38 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1993-04-04 14:41:38 +0000 |
commit | a92a94f719519ab5a06a2b704c656de9b4c4dc1c (patch) | |
tree | 0539f01dbe189f038925e9fb4e5bd111df213c12 /src | |
parent | dc932e0a18cfa5a754dbfae62457d8ed7fffa2e7 (diff) | |
download | coreutils-a92a94f719519ab5a06a2b704c656de9b4c4dc1c.tar.xz |
(usage): Mention --help and --version.
(main): Handle flag_help and flag_version before checking for invocation errors.
Diffstat (limited to 'src')
-rw-r--r-- | src/chgrp.c | 8 | ||||
-rw-r--r-- | src/chmod.c | 14 | ||||
-rw-r--r-- | src/chown.c | 8 | ||||
-rw-r--r-- | src/cp.c | 6 | ||||
-rw-r--r-- | src/dd.c | 2 | ||||
-rw-r--r-- | src/df.c | 2 | ||||
-rw-r--r-- | src/du.c | 10 | ||||
-rw-r--r-- | src/install.c | 16 | ||||
-rw-r--r-- | src/ln.c | 7 | ||||
-rw-r--r-- | src/ls.c | 3 | ||||
-rw-r--r-- | src/mkdir.c | 8 | ||||
-rw-r--r-- | src/mkfifo.c | 8 | ||||
-rw-r--r-- | src/mknod.c | 6 | ||||
-rw-r--r-- | src/mv.c | 8 | ||||
-rw-r--r-- | src/rm.c | 2 | ||||
-rw-r--r-- | src/rmdir.c | 8 | ||||
-rw-r--r-- | src/touch.c | 2 |
17 files changed, 63 insertions, 55 deletions
diff --git a/src/chgrp.c b/src/chgrp.c index 2dba1eed4..31a74259c 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -125,15 +125,15 @@ main (argc, argv) } } - if (optind >= argc - 1) - usage (); - if (flag_version) fprintf (stderr, "%s\n", version_string); if (flag_help) usage (); + if (optind >= argc - 1) + usage (); + parse_group (argv[optind++], &group); for (; optind < argc; ++optind) @@ -292,7 +292,7 @@ usage () { fprintf (stderr, "\ Usage: %s [-Rcfv] [--recursive] [--changes] [--silent] [--quiet]\n\ - [--verbose] group file...\n", + [--verbose] [--help] [--version] group file...\n", program_name); exit (1); } diff --git a/src/chmod.c b/src/chmod.c index de93b0f0c..b955b3f88 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -140,17 +140,18 @@ main (argc, argv) } } - if (modeind == 0) - modeind = optind++; - if (optind >= argc) - usage (); - if (flag_version) fprintf (stderr, "%s\n", version_string); if (flag_help) usage (); + if (modeind == 0) + modeind = optind++; + + if (optind >= argc) + usage (); + changes = mode_compile (argv[modeind], MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS); if (changes == MODE_INVALID) @@ -288,7 +289,8 @@ static void usage () { fprintf (stderr, "\ -Usage: %s [-Rcfv] mode file...\n\ +Usage: %s [-Rcfv] [--recursive] [--changes] [--silent] [--quiet]\n\ + [--verbose] [--help] [--version] mode file...\n\ mode is [ugoa...][[+-=][rwxXstugo...]...][,...] or octal number\n", program_name); exit (1); diff --git a/src/chown.c b/src/chown.c index e693e662a..3971175e2 100644 --- a/src/chown.c +++ b/src/chown.c @@ -137,15 +137,15 @@ main (argc, argv) } } - if (optind >= argc - 1) - usage (); - if (flag_version) fprintf (stderr, "%s\n", version_string); if (flag_help) usage (); + if (optind >= argc - 1) + usage (); + e = parse_user_spec (argv[optind], &user, &group, &username, &groupname); if (e) error (1, 0, "%s: %s", argv[optind], e); @@ -280,7 +280,7 @@ usage () { fprintf (stderr, "\ Usage: %s [-Rcfv] [--recursive] [--changes] [--silent] [--quiet]\n\ - [--verbose] [user][:.][group] file...\n", + [--verbose] [--help] [--version] [user][:.][group] file...\n", program_name); exit (1); } @@ -258,15 +258,15 @@ main (argc, argv) } } - if (flag_hard_link && flag_symbolic_link) - usage ("cannot make both hard and symbolic links"); - if (flag_version) fprintf (stderr, "%s\n", version_string); if (flag_help) usage (NULL); + if (flag_hard_link && flag_symbolic_link) + usage ("cannot make both hard and symbolic links"); + if (make_backups) backup_type = get_version (version); @@ -1059,7 +1059,7 @@ usage () Usage: %s [if=file] [of=file] [ibs=bytes] [obs=bytes] [bs=bytes] [cbs=bytes]\n\ [skip=blocks] [seek=blocks] [count=blocks]\n\ [conv={ascii,ebcdic,ibm,block,unblock,lcase,ucase,swab,noerror,notrunc,\n\ - sync}]\n\ + sync}] [--help] [--version]\n\ Numbers can be followed by a multiplier:\n\ b=512, k=1024, w=2, xm=number m\n", program_name); @@ -458,7 +458,7 @@ usage () fprintf (stderr, "\ Usage: %s [-aikPv] [-t fstype] [-x fstype] [--all] [--inodes]\n\ \t[--type=fstype] [--exclude-type=fstype] [--kilobytes] [--portability]\n\ -\t[path...]\n", +\t[--help] [--version] [path...]\n", program_name); exit (1); } @@ -188,7 +188,7 @@ usage (reason) fprintf (stderr, "\ Usage: %s [-abcklsxDLS] [--all] [--total] [--count-links] [--summarize]\n\ [--bytes] [--kilobytes] [--one-file-system] [--separate-dirs]\n\ - [--dereference] [--dereference-args] [path...]\n", + [--dereference] [--dereference-args] [--help] [--version] [path...]\n", program_name); exit (2); @@ -258,14 +258,14 @@ main (argc, argv) } } - if (opt_all && opt_summarize_only) - usage ("cannot both summarize and show all entries"); - if (flag_version) fprintf (stderr, "%s\n", version_string); if (flag_help) - usage (""); + usage (NULL); + + if (opt_all && opt_summarize_only) + usage ("cannot both summarize and show all entries"); /* Initialize the hash structure for inode numbers. */ hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE); diff --git a/src/install.c b/src/install.c index dd8b58cc7..d2ad40b0b 100644 --- a/src/install.c +++ b/src/install.c @@ -194,18 +194,18 @@ main (argc, argv) } } - /* Check for invalid combinations of arguments. */ - if ((dir_arg && strip_files) - || (optind == argc) - || (optind == argc - 1 && !dir_arg)) - usage (); - if (flag_version) fprintf (stderr, "%s\n", version_string); if (flag_help) usage (); + /* Check for invalid combinations of arguments. */ + if ((dir_arg && strip_files) + || (optind == argc) + || (optind == argc - 1 && !dir_arg)) + usage (); + if (symbolic_mode) { struct mode_change *change = mode_compile (symbolic_mode, 0); @@ -511,8 +511,8 @@ Usage: %s [options] [-s] [--strip] source dest\n\ %s [options] [-s] [--strip] source... directory\n\ %s [options] {-d,--directory} directory...\n\ Options:\n\ - [-c] [-g group] [-m mode] [-o owner]\n\ - [--group=group] [--mode=mode] [--owner=owner]\n", + [-c] [-g group] [-m mode] [-o owner] [--group=group]\n\ + [--help] [--version] [--mode=mode] [--owner=owner]\n", program_name, program_name, program_name); exit (1); } @@ -148,8 +148,6 @@ main (argc, argv) break; } } - if (optind == argc) - usage (); if (flag_version) fprintf (stderr, "%s\n", version_string); @@ -157,6 +155,9 @@ main (argc, argv) if (flag_help) usage (); + if (optind == argc) + usage (); + if (make_backups) backup_type = get_version (version); @@ -303,7 +304,7 @@ Options:\n\ [-bdfisvF] [-S backup-suffix] [-V {numbered,existing,simple}]\n\ [--version-control={numbered,existing,simple}] [--backup] [--directory]\n\ [--force] [--interactive] [--symbolic] [--verbose]\n\ - [--suffix=backup-suffix]\n", + [--suffix=backup-suffix] [--help] [--version]\n", program_name, program_name); exit (1); } @@ -1859,6 +1859,7 @@ Usage: %s [-abcdgiklmnpqrstuxABCFGLNQRSUX1] [-w cols] [-T cols] [-I pattern]\n\ [--classify] [--file-type] [--ignore=pattern] [--dereference]\n\ [--quote-name] [--recursive] [--sort={none,time,size,extension}]\n\ [--format={long,verbose,commas,across,vertical,single-column}]\n\ - [--time={atime,access,use,ctime,status}] [--no-group] [path...]\n"); + [--time={atime,access,use,ctime,status}] [--no-group]\n\ + [--help] [--version] [path...]\n"); exit (1); } diff --git a/src/mkdir.c b/src/mkdir.c index 3d98ac627..e9da99beb 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -91,15 +91,15 @@ main (argc, argv) } } - if (optind == argc) - usage (); - if (flag_version) fprintf (stderr, "%s\n", version_string); if (flag_help) usage (); + if (optind == argc) + usage (); + newmode = 0777 & ~umask (0); parent_mode = newmode | 0300; /* u+wx */ if (symbolic_mode) @@ -130,7 +130,7 @@ static void usage () { fprintf (stderr, "\ -Usage: %s [-p] [-m mode] [--path] [--mode=mode] dir...\n", +Usage: %s [-p] [-m mode] [--path] [--mode=mode] [--help] [--version] dir...\n", program_name); exit (1); } diff --git a/src/mkfifo.c b/src/mkfifo.c index a6a78f105..be765f488 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -79,15 +79,15 @@ main (argc, argv) } } - if (optind == argc) - usage (); - if (flag_version) fprintf (stderr, "%s\n", version_string); if (flag_help) usage (); + if (optind == argc) + usage (); + newmode = 0666 & ~umask (0); if (symbolic_mode) { @@ -117,7 +117,7 @@ static void usage () { fprintf (stderr, "\ -Usage: %s [-m mode] [--mode=mode] path...\n", +Usage: %s [-m mode] [--mode=mode] [--help] [--version] path...\n", program_name); exit (1); } diff --git a/src/mknod.c b/src/mknod.c index 7e65ac01f..08f3f8959 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -152,8 +152,10 @@ static void usage () { fprintf (stderr, "\ -Usage: %s [-m mode] [--mode=mode] path {bcu} major minor\n\ - %s [-m mode] [--mode=mode] path p\n", +Usage: %s [options] path {bcu} major minor\n\ + %s [options] path p\n\ +Options:\n\ + [-m mode] [--mode=mode] [--help] [--version]\n", program_name, program_name); exit (1); } @@ -160,8 +160,6 @@ main (argc, argv) usage (); } } - if (argc < optind + 2) - usage (); if (flag_version) fprintf (stderr, "%s\n", version_string); @@ -169,6 +167,9 @@ main (argc, argv) if (flag_help) usage (); + if (argc < optind + 2) + usage (); + if (make_backups) backup_type = get_version (version); @@ -447,7 +448,8 @@ Usage: %s [options] source dest\n\ Options:\n\ [-bfiuv] [-S backup-suffix] [-V {numbered,existing,simple}]\n\ [--backup] [--force] [--interactive] [--update] [--verbose]\n\ - [--suffix=backup-suffix] [--version-control={numbered,existing,simple}]\n", + [--suffix=backup-suffix] [--version-control={numbered,existing,simple}]\n\ + [--help] [--version]\n", program_name, program_name); exit (1); } @@ -514,7 +514,7 @@ usage () { fprintf (stderr, "\ Usage: %s [-dfirvR] [--directory] [--force] [--interactive] [--recursive]\n\ - [--verbose] path...\n", + [--verbose] [--help] [--version] path...\n", program_name); exit (1); } diff --git a/src/rmdir.c b/src/rmdir.c index aaaeb4df6..a53235389 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -79,15 +79,15 @@ main (argc, argv) } } - if (optind == argc) - usage (); - if (flag_version) fprintf (stderr, "%s\n", version_string); if (flag_help) usage (); + if (optind == argc) + usage (); + for (; optind < argc; ++optind) { /* Stripping slashes is harmless for rmdir; @@ -131,7 +131,7 @@ remove_parents (path) static void usage () { - fprintf (stderr, "Usage: %s [-p] [--path] dir...\n", + fprintf (stderr, "Usage: %s [-p] [--path] [--help] [--version] dir...\n", program_name); exit (1); } diff --git a/src/touch.c b/src/touch.c index 7be500bdf..65072176b 100644 --- a/src/touch.c +++ b/src/touch.c @@ -366,7 +366,7 @@ usage () fprintf (stderr, "\ Usage: %s [-acfm] [-r reference-file] [-t MMDDhhmm[[CC]YY][.ss]]\n\ [-d time] [--time={atime,access,use,mtime,modify}] [--date=time]\n\ - [--file=reference-file] [--no-create] file...\n", + [--file=reference-file] [--no-create] [--help] [--version] file...\n", program_name); exit (1); } |