]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(usage): Mention --help and --version.
authorJim Meyering <jim@meyering.net>
Sun, 4 Apr 1993 14:41:38 +0000 (14:41 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 4 Apr 1993 14:41:38 +0000 (14:41 +0000)
(main): Handle flag_help and flag_version before checking for invocation errors.

17 files changed:
src/chgrp.c
src/chmod.c
src/chown.c
src/cp.c
src/dd.c
src/df.c
src/du.c
src/install.c
src/ln.c
src/ls.c
src/mkdir.c
src/mkfifo.c
src/mknod.c
src/mv.c
src/rm.c
src/rmdir.c
src/touch.c

index 2dba1eed4a4ab645995de1497bf12b5a00ac9a4a..31a74259cf8d20cfdf55da8007100fcc3adba551 100644 (file)
@@ -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);
 }
index de93b0f0ca41447fdca34aee2a1a0ae07786988b..b955b3f8892360dd8f83208dfee7a06aed3294bd 100644 (file)
@@ -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);
index e693e662a3115108550c910801ed45c0f484f87d..3971175e2def921d43e6602022c76a64ff59d41f 100644 (file)
@@ -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);
 }
index f3a7c0a974fbfb79370ef5fd7a9008235526b3f7..830861d0e1dd6b1eaaefd122b19b0e4399df33a8 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -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);
 
index 06d9f6e2461329d77f488ea104723d0a942df972..3c89df6b82dbf4be2cddbf7aea4eeba3d50a7827 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -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);
index bdc834cac71a8e152426d9dd8a260dbbd47cc578..af74503ebcd30c3bc162d1a825b525ac7e7c5c99 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -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);
 }
index 90cb303b0bab95a6a0c6c484ed2ec09cbcc4a4cc..3d845e90c43a53364c31998f2afdccc710c7ade7 100644 (file)
--- a/src/du.c
+++ b/src/du.c
@@ -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);
index dd8b58cc73c21076d7e6075dd4dac4f0be531b43..d2ad40b0b143ed5b4f2a462cd52ecbc236ff2d75 100644 (file)
@@ -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);
 }
index 67341036374ffacf404853320bebf8b5aab11e93..ccad07769b2a680ead79d63b9efa6aa227edec5c 100644 (file)
--- a/src/ln.c
+++ b/src/ln.c
@@ -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);
 }
index a171664afbb2e30d9909f80c0e8a5b73d4f479ec..f50426b8dc51dca20e8108a1893994ec25f122ec 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -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);
 }
index 3d98ac6271e7902c78f2b9e3b5ef8be6d21eae88..e9da99beb11b0769de3f93126a374e6e28b8e93f 100644 (file)
@@ -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);
 }
index a6a78f105f57d3f895c7ab4bd255acffb2373035..be765f4889fd23bb27c0903f564dd56734091328 100644 (file)
@@ -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);
 }
index 7e65ac01f5e6438ddef8cc9d161126535d757902..08f3f89593d7e981a06e84f6e9618ab0558a7a8a 100644 (file)
@@ -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);
 }
index 91906e1393e14a7c5b8a6048d5ad6cc9f8035b5a..05a8fa11fc8ffcb7e265fb9811c4ed8ecb985032 100644 (file)
--- a/src/mv.c
+++ b/src/mv.c
@@ -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);
 }
index 0dec9d133ea14f6b706cfae53ca1f05fd0a7836b..d0f98dad1f8aac1c919d6b889de9d10641b1fcda 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -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);
 }
index aaaeb4df6e89f8b7a634adb0de9b35785786bb43..a53235389264b1b0889b2e13fa5b90315aca8802 100644 (file)
@@ -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);
 }
index 7be500bdf30476d03e8ccf7c547b839e4185aa28..65072176baaf8585783e421d39caec27fb5cd583 100644 (file)
@@ -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);
 }