merge with 3.8.3d
authorJim Meyering <jim@meyering.net>
Fri, 8 Oct 1993 00:51:10 +0000 (00:51 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 8 Oct 1993 00:51:10 +0000 (00:51 +0000)
20 files changed:
lib/Makefile.in
old/fileutils/ChangeLog
old/fileutils/NEWS
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 a23873c..cbf2bd6 100644 (file)
@@ -27,6 +27,10 @@ DEFS = -DMVDIR="\"$(libdir)/mvdir\"" @DEFS@
 CFLAGS = @CFLAGS@
 YACC = @YACC@
 
+prefix = /usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+
 SOURCES = getdate.y posixtm.y \
 argmatch.c backupfile.c basename.c dirname.c eaccess.c \
 error.c filemode.c fsusage.c getopt.c getopt1.c \
index 935aa55..05b42e2 100644 (file)
@@ -1,3 +1,16 @@
+Thu Oct 07 12:57:10 1993  Jim Meyering  (meyering@comco.com)
+
+       * chgrp.c, chmod.c, chown.c, cp-aux.c, cp.c, dd.c, df.c, du.c,
+       install.c, ln.c, ls.c, mkdir.c, mkfifo.c, mknod.c, mv.c, mvdir.c,
+       rm.c, rmdir.c, touch.c (usage): Using --help gets long well-
+       formatted help.  Now --help writes to stdout and exits successfully.
+       From Francois Pinard <pinard@iro.umontreal.ca>.
+
+       * lib/Makefile.in [libdir]: Make sure it's defined.
+
+        * posixtm.y [!__GNUC__ && !HAVE_ALLOCA_H]: Declare alloca as void*
+        rather than char*.  The latter conflicts with a dcl from bison.simple.
+
 Wed Oct 06 18:22:00 1993  Jim Meyering  (meyering@comco.com)
 
        * chmod.c (change_file_mode): Add an argument to control how symbolic
@@ -127,7 +140,7 @@ Mon Jul 19 17:39:01 1993  Jim Meyering  (meyering@comco.com)
 Fri Jul 16 22:00:16 1993  David J. MacKenzie  (djm@goldman.gnu.ai.mit.edu)
 
        * dd.c (print_stats): Change message from "truncated blocks"
-       to "truncated records" for final POSIX.2 spec. 
+       to "truncated records" for final POSIX.2 spec.
 
 Fri Jun 25 17:18:15 1993  Jim Meyering  (meyering@comco.com)
 
@@ -315,7 +328,7 @@ Sun Apr 18 02:35:36 1993  Jim Meyering  (meyering@comco.com)
 
        * src/Makefile.in (install): Rewrite the test for whether to install
        mvdir so that it doesn't cause gratuitous failures with broken shells.
-       Split long rule so the pieces fit in 80-column lines. 
+       Split long rule so the pieces fit in 80-column lines.
 
 Thu Apr 15 23:44:01 1993  Jim Meyering  (meyering@comco.com)
 
@@ -766,7 +779,7 @@ Sat Mar 28 00:36:57 1992  David J. MacKenzie  (djm@wookumz.gnu.ai.mit.edu)
        whether to do it once per buffer read, instead of once per character.
        (copy): If conv=block and the input didn't end with a newline,
        pad the final block with spaces.
+
 Wed Mar 25 14:35:17 1992  David J. MacKenzie  (djm@wookumz.gnu.ai.mit.edu)
 
        * system.h: Don't use BSIZE for calculating ST_BLKSIZE if it
@@ -953,7 +966,7 @@ Sun Aug 25 00:56:11 1991  David J. MacKenzie  (djm at apple-gunkies)
 
        * df.c, fsinfo.c, fsinfo.h: New program.
        * configure: Check for various ways of getting info on mounted
-       filesystems. 
+       filesystems.
 
 Thu Aug 22 10:53:23 1991  David J. MacKenzie  (djm at apple-gunkies)
 
@@ -1112,7 +1125,7 @@ Sat Jul  6 02:19:09 1991  David J. MacKenzie  (djm at geech.gnu.ai.mit.edu)
 
        * configure: echo messages to stdout, not stderr.
        Use test programs to see if alloca needs -lPW and if chars are
-       unsigned. 
+       unsigned.
 
 Tue Jul  2 03:16:32 1991  David J. MacKenzie  (djm at geech.gnu.ai.mit.edu)
 
@@ -1202,7 +1215,7 @@ Sat Jun  8 11:02:32 1991  David J. MacKenzie  (djm at geech.gnu.ai.mit.edu)
 
        * backupfile.c: Use POSIX instead of _POSIX_SOURCE to
        determine whether to check whether readdir returned a valid
-       entry. 
+       entry.
 
 Fri Jun  7 21:44:51 1991  David J. MacKenzie  (djm at geech.gnu.ai.mit.edu)
 
@@ -1288,7 +1301,7 @@ Mon Feb 25 11:44:14 1991  David J. MacKenzie  (djm at geech.ai.mit.edu)
 
        * dd.c (copy): Only seek if not seeking to start of file, so
        "dd >> foo" works with Minix shell that doesn't open foo in
-       append mode. 
+       append mode.
 
 Thu Feb 21 11:59:39 1991  David J. MacKenzie  (djm at geech.ai.mit.edu)
 
@@ -1319,7 +1332,7 @@ Thu Jan 10 02:16:55 1991  David J. MacKenzie  (djm at albert.ai.mit.edu)
 Fri Dec 28 18:40:34 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
        * chmod.c, chown.c, chgrp.c, du.c: Rename -d option to -L for
-       similarity to ls and cpio. 
+       similarity to ls and cpio.
 
 Thu Dec 27 00:06:45 1990  David J. MacKenzie  (djm at egypt)
 
@@ -1411,7 +1424,7 @@ Sat Oct 27 23:38:55 1990  David J. MacKenzie  (djm at apple-gunkies)
        * rm.c (check_stack): If not interactive, don't prompt when
        corruption is found, just quit.
        (remove_file, remove_dir): Delete leading spaces in verbose
-       output. 
+       output.
 
        * cp.c (copy), rm.c (remove_dir): If we think the dest. file
        is unwritable, warn the user in the interactive prompt instead
@@ -1530,7 +1543,7 @@ Wed Aug 22 01:45:54 1990  David J. MacKenzie  (djm at apple-gunkies)
 
        * du.c: Rename -f option to -x, for POSIX.  Rename
        +kilobyte-file-size to +kilobytes.  Add -b, +bytes option for
-       POSIX. 
+       POSIX.
 
        * cp-aux.c (usage): Change -o to -x.
        (stpcpy): Renamed from str_cpy.  Change callers in cp.c.
@@ -1638,7 +1651,7 @@ Tue Jul 24 03:39:42 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
 Mon Jul 23 16:57:44 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
-       * cp.c (copy): Make +update operate silently, like +one-file-system. 
+       * cp.c (copy): Make +update operate silently, like +one-file-system.
 
        * ln.c: Add -F as synonym for -d, for SunOS compatibility.
 
@@ -1656,7 +1669,7 @@ Sun Jul  8 00:39:31 1990  David J. MacKenzie  (djm at apple-gunkies)
 
        * rm.c (main, usage): Add new option -d, +directory.
        (rm): If -d given, use remove_file instead of remove_dir for
-       directories. 
+       directories.
        (remove_file): If directory, print "remove directory `foo'?"
        for interactive instead of "remove `foo'?".
 
@@ -1671,12 +1684,12 @@ Fri Jul  6 02:02:49 1990  David J. MacKenzie  (djm at apple-gunkies)
        default owner and group.
 
        * mv.c (main): New option -u, +update.
-       (do_move): Don't move nondirectories if -u and there is an existing 
+       (do_move): Don't move nondirectories if -u and there is an existing
        destination that has the same or newer mtime.
        (usage): Document -u, +update.
 
        * cp.c (main): New option -u, +update.
-       (copy): Don't copy nondirectories if -u and there is an existing 
+       (copy): Don't copy nondirectories if -u and there is an existing
        destination that has the same or newer mtime.
        * cp-aux.c (usage): Document -u ,+update.
 
@@ -1729,7 +1742,7 @@ Fri Jun 22 00:38:20 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
        * rm.c, rmdir.c, mkdir.c, mkfifo.c: Move code to remove
        slashes at the end of an arg from main to
-       strip_trailing_slashes. 
+       strip_trailing_slashes.
 
        * install.c (strip): Print error message if the `strip'
        program can't be run.
@@ -1741,7 +1754,7 @@ Fri Jun 22 00:38:20 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
 Thu Jun 21 01:19:28 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
-       * ls.c (print_long_format): Use mode_string instead of filemodestring. 
+       * ls.c (print_long_format): Use mode_string instead of filemodestring.
 
        * ls.c (print_long_format): Compare times as longs, not ints.
        (longdiff): Macro to compare two longs efficiently if sizeof
@@ -1793,7 +1806,7 @@ Sun Jun 17 00:09:23 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 Sat Jun 16 01:45:42 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
        * argmatch.c (invalid_arg): Change order in which the items
-       are printed. 
+       are printed.
 
        * ls.c: Add +tabsize (-T) option.
 
@@ -1870,7 +1883,7 @@ Sat May 19 00:16:50 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
        * mv.c (usage), ln.c (usage), cp-aux.c (usage): Revise messages.
 
        * chmod.c (describe_change): Use mode_string instead of
-       filemodestring. 
+       filemodestring.
 
        * cp.c (main): Recognize new options for making backups.
        * cp.c (copy): Make backups if requested.  Fix typo.
@@ -1909,7 +1922,7 @@ Mon May 14 14:34:10 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
        * dd.c: Make translation tables unsigned.
        (main): Give `input_file' and `output_file' nonzero values for
-       stdin and stdout. 
+       stdin and stdout.
        (parse_conversion): Set new global vars 'space_character' and
        'newline_character' to correct values when translating to EBCDIC
        (either flavor).
@@ -1924,7 +1937,7 @@ Mon May 14 14:34:10 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 Sat May 12 01:16:42 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
        * cp-hash (remember_created): Return error status instead of
-       fatal error. 
+       fatal error.
        * cp.c (copy): Change caller.
        (do_copy, copy_reg): Return error status instead of fatal error.
 
@@ -1942,7 +1955,7 @@ Sat May 12 01:16:42 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 Fri May 11 02:11:03 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
        * ln.c, mv.c, rm.c, rmdir.c, create.c, chmod.c: Change some
-       error messages. 
+       error messages.
 
        * du.c, cp-aux.c (error): Function removed.
        Change callers to use error.c version.
@@ -1986,7 +1999,7 @@ Sat Apr 14 17:23:11 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
        * ls.c (main): Don't remove leading path from program_name.
        (basename): Function removed.
        (length_of_file_name_and_frills): Don't add 1 for type indicator
-       for block and character special files. 
+       for block and character special files.
 
 Thu Apr 12 19:50:15 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
@@ -2023,7 +2036,7 @@ Sun Apr  8 20:33:20 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
        * rm.c (remove_file): Ditto.
        (remove_dir): Use eaccess_stat to determine readability and
        searchability.  Move initial interactive query here from
-       clear_directory. 
+       clear_directory.
        * Makefile: Link ln, mv, and rm with eaccess.o.
 
 Sat Apr  7 11:47:52 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
@@ -2067,7 +2080,7 @@ Sun Apr  1 18:53:57 1990  David J. MacKenzie  (djm at spike.ai.mit.edu)
 Sat Mar 31 22:29:57 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
        * mv.c [RENAME_MISSING] (rename): To rename directories, run
-       setuid root mv_dir program. 
+       setuid root mv_dir program.
 
 Tue Mar 20 14:28:25 1990  David J. MacKenzie  (djm at pogo.ai.mit.edu)
 
@@ -2100,17 +2113,17 @@ Sat Mar 17 21:45:35 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
        * cp-aux.c, cp.h: Rename user_confirm_overwriting to yesno and
        don't have it print a prompt, so it can be used in several
-       places. 
+       places.
 
        * cp.c (do_copy): Change an error message to resemble mv's.
        Remove all trailing slashes from all non-option args.
        (main): Set new global var `stdin_not_tty'.
        (copy): Use POSIX method of handling file overwriting and
-       prompting. 
+       prompting.
 
        * dirlib.c (mkdir): Use chmod to set the directory mode after
        successful creation, so set[ug]id and sticky bits are set
-       correctly. 
+       correctly.
 
 Thu Mar 15 12:33:23 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
@@ -2124,7 +2137,7 @@ Thu Mar 15 12:33:23 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
        Global: Call error instead of the above functions.
        (change_dir_mode): Make the new size of the path twice the
        size of the name that was too long, rather than twice its old
-       size. 
+       size.
 
        * rm.c: Move interactive query about whether to remove a
        directory from remove_dir to clear_directory; only query for
@@ -2183,7 +2196,7 @@ Tue Mar 13 00:50:14 1990  David J. MacKenzie  (djm at rice-chex)
 
        * Makefile (CC): Add comment noting that either fixincludes or
        -traditional needs to be used for gcc to compile ioctl calls
-       correctly. 
+       correctly.
 
 Mon Mar 12 16:25:23 1990  Jim Kingdon  (kingdon at pogo.ai.mit.edu)
 
@@ -2236,7 +2249,7 @@ Mon Mar  5 00:34:36 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
        (do_move): Simplify check for query.  Rename `stb' to
        `to_stats' and `stbf' to `from_stats'.
        Return error condition if original file could not be renamed or
-       unlinked. 
+       unlinked.
 
        * rm.c: Rename global `force_flag' to `ignore_errors' and change its
        meaning so that it does not overlap with `override_mode'.
@@ -2249,7 +2262,7 @@ Sun Mar  4 23:39:03 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)
 
        * ln.c (main): Reword an error message to be more like mv's.
 
-       * rmdir.c: Move global `errors' into main instead of having 
+       * rmdir.c: Move global `errors' into main instead of having
        error set it.
 
        * mkdir.c: Move global `errors' into main and have make_path
@@ -2399,7 +2412,7 @@ Mon Feb 12 11:30:45 1990  David J. MacKenzie  (djm at rice-chex)
 
        * du.c (main): Check error return from stat.
        (str_copyc, str_concatc): Don't return a value, since it is
-       ignored. 
+       ignored.
 
        * cp.c (copy): Check error return from unlink and chmod.  Fix
        typo in call to error.
index 87ebbbd..831704f 100644 (file)
@@ -1,4 +1,6 @@
 Major changes in release 3.9:
+* --help gives one-line description of options and shows correspondence
+  between short and long-named options.
 * GNU chmod treats symlinks the same way other vendor's versions do.
   Now symlinks listed on the command line are processed (they were
   ignored before); the permissions of the dereferenced files are
index ca66a59..b148476 100644 (file)
@@ -134,7 +134,7 @@ main (argc, argv)
          verbose = 1;
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -145,10 +145,10 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (optind >= argc - 1)
-    usage ();
+    usage (1);
 
   parse_group (argv[optind++], &group);
 
@@ -304,11 +304,26 @@ isnumber (str)
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-Usage: %s [-Rcfv] [--recursive] [--changes] [--silent] [--quiet]\n\
-       [--verbose] [--help] [--version] group file...\n",
+Usage: %s [OPTION]... GROUP FILE...\n\
+\n",
           program_name);
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -c, --changes           be verbose whenever change occurs\n\
+  -f, --silent, --quiet   avoid most error messages\n\
+  -v, --verbose           explain what is being done\n\
+  -R, --recursive         change files and directories recursively\n\
+      --help              provide this help\n\
+      --version           show program version\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index 511e3e2..9df0c33 100644 (file)
@@ -149,7 +149,7 @@ main (argc, argv)
          verbose = 1;
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -160,13 +160,13 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (modeind == 0)
     modeind = optind++;
 
   if (optind >= argc)
-    usage ();
+    usage (1);
 
   changes = mode_compile (argv[modeind],
                          MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS);
@@ -302,12 +302,30 @@ describe_change (file, mode, changed)
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-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);
+Usage: %s [OPTION]... MODE[,MODE]... FILE...\n\
+  or:  %s [OPTION]... OCTAL_MODE FILE...\n\
+\n",
+          program_name, program_name);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -c, --changes           be verbose whenever change occurs\n\
+  -f, --silent, --quiet   avoid most error messages\n\
+  -v, --verbose           explain what is being done\n\
+  -R, --recursive         change files and directories recursively\n\
+      --help              provide this help\n\
+      --version           show program version\n\
+\n\
+Each MODE is one or more of letters ugoa, one of the signs +-= and one\n\
+or more of letters rwxXstugo.\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index c295f58..1584883 100644 (file)
@@ -15,7 +15,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
-/* 
+/*
               |                      user
               | unchanged                 explicit
  -------------|-------------------------+-------------------------|
@@ -146,7 +146,7 @@ main (argc, argv)
          verbose = 1;
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -157,10 +157,10 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (optind >= argc - 1)
-    usage ();
+    usage (1);
 
   e = parse_user_spec (argv[optind], &user, &group, &username, &groupname);
   if (e)
@@ -292,11 +292,30 @@ describe_change (file, changed)
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-Usage: %s [-Rcfv] [--recursive] [--changes] [--silent] [--quiet]\n\
-       [--verbose] [--help] [--version] [user][:.][group] file...\n",
-          program_name);
-  exit (1);
+Usage: %s [OPTION]... OWNER[.[GROUP]] FILE...\n\
+  or:  %s [OPTION]... .[GROUP] FILE...\n\
+\n",
+          program_name, program_name);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -c, --changes           be verbose whenever change occurs\n\
+  -f, --silent, --quiet   avoid most error messages\n\
+  -v, --verbose           explain what is being done\n\
+  -R, --recursive         change files and directories recursively\n\
+      --help              provide this help\n\
+      --version           show program version\n\
+\n\
+Owner is unchanged if missing.  Group is unchanged is missing, but changed\n\
+to login group if implied by a period.  A colon may replace the period.\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index c1ae72c..5d88f99 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -268,7 +268,7 @@ main (argc, argv)
          break;
 
        default:
-         usage ((char *) 0);
+         usage ((char *) 0, 2);
        }
     }
 
@@ -279,10 +279,10 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage (NULL);
+    usage (NULL, 0);
 
   if (flag_hard_link && flag_symbolic_link)
-    usage ("cannot make both hard and symbolic links");
+    usage ("cannot make both hard and symbolic links", 2);
 
   if (make_backups)
     backup_type = get_version (version);
@@ -321,9 +321,9 @@ do_copy (argc, argv)
   int ret = 0;
 
   if (optind >= argc)
-    usage ("missing file arguments");
+    usage ("missing file arguments", 2);
   if (optind >= argc - 1)
-    usage ("missing file argument");
+    usage ("missing file argument", 2);
 
   dest = argv[argc - 1];
 
@@ -405,7 +405,7 @@ do_copy (argc, argv)
            {
              ret |= copy (arg, dst_path, new_dst, 0, (struct dir_list *) 0);
              forget_all ();
-  
+
              if (flag_path)
                {
                  ret |= re_protect (dst_path, strlen (dest) + 1,
@@ -427,7 +427,7 @@ do_copy (argc, argv)
       struct stat source_stats;
 
       if (flag_path)
-       usage ("when preserving paths, last argument must be a directory");
+       usage ("when preserving paths, last argument must be a directory", 2);
 
       source = argv[optind];
 
@@ -459,7 +459,8 @@ do_copy (argc, argv)
       return copy (source, new_dest, new_dst, 0, (struct dir_list *) 0);
     }
   else
-    usage ("when copying multiple files, last argument must be a directory");
+    usage ("when copying multiple files, last argument must be a directory",
+          2);
 }
 \f
 /* Copy the file SRC_PATH to the file DST_PATH.  The files may be of
@@ -882,7 +883,7 @@ make_path (const_dirpath, src_offset, mode, verbose_fmt_string,
 
   src = dirpath + src_offset;
 
-  tmp_dst_dirname = dirname (dirpath); 
+  tmp_dst_dirname = dirname (dirpath);
   dst_dirname = (char *) alloca (strlen (tmp_dst_dirname) + 1);
   strcpy (dst_dirname, tmp_dst_dirname);
   free (tmp_dst_dirname);
@@ -998,7 +999,7 @@ re_protect (const_dst_path, src_offset, attr_list)
 
   dst_path = (char *) alloca (strlen (const_dst_path) + 1);
   strcpy (dst_path, const_dst_path);
-  src_path = dst_path + src_offset; 
+  src_path = dst_path + src_offset;
 
   for (p = attr_list; p; p = p->next)
     {
index bde611c..88c2c28 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -359,7 +359,7 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   apply_translations ();
 
@@ -394,7 +394,7 @@ main (argc, argv)
     }
   else
     output_file = "standard output";
-  
+
 #ifdef _POSIX_VERSION
   sigaction (SIGINT, NULL, &sigact);
   if (sigact.sa_handler != SIG_IGN)
@@ -705,7 +705,7 @@ copy_simple (buf, nread)
        nfree = nread;
 
       bcopy (start, obuf + oc, nfree);
-           
+
       nread -= nfree;          /* Update the number of bytes left to copy. */
       start += nfree;
       oc += nfree;
@@ -822,7 +822,7 @@ scanargs (argc, argv)
          break;
 
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -835,7 +835,7 @@ scanargs (argc, argv)
       if (val == NULL)
        {
          error (0, 0, "unrecognized option `%s'", name);
-         usage ();
+         usage (1);
        }
       *val++ = '\0';
 
@@ -874,7 +874,7 @@ scanargs (argc, argv)
          else
            {
              error (0, 0, "unrecognized option `%s=%s'", name, val);
-             usage ();
+             usage (1);
            }
        }
     }
@@ -960,7 +960,7 @@ parse_conversion (str)
       if (conversions[i].convname == NULL)
        {
          error (0, 0, "%s: invalid conversion", str);
-         usage ();
+         usage (1);
        }
       str = new;
   } while (new != NULL);
@@ -1070,15 +1070,46 @@ interrupt_handler ()
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-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}] [--help] [--version]\n\
-Numbers can be followed by a multiplier:\n\
-b=512, c=1, k=1024, w=2, xm=number m\n",
+Usage: %s [OPTION]...\n\
+\n",
           program_name);
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  bs=BYTES        force ibs=BYTES and obs=BYTES\n\
+  cbs=BYTES       convert BYTES bytes at a time\n\
+  conv=KEYWORDS   convert the file as per the comma separated keyword list\n\
+  count=BLOCKS    copy only BLOCKS input blocks\n\
+  ibs=BYTES       read BYTES bytes at a time\n\
+  if=FILE         read from FILE instead of stdin\n\
+  obs=BYTES       write BYTES bytes at a time\n\
+  of=FILE         write to FILE instead of stdout, don't truncate file\n\
+  seek=BLOCKS     skip BLOCKS obs-sized blocks at start of output\n\
+  skip=BLOCKS     skip BLOCKS ibs-sized blocks at start of input\n\
+      --help      provide this help\n\
+      --version   show program version\n\
+\n\
+BYTES may be suffixed: by xM for multiplication by M, by c for x1,\n\
+by w for x2, by b for x512, by k for x1024.  Each KEYWORD may be:\n\
+\n\
+  ascii     from EBCDIC to ASCII\n\
+  ebcdic    from ASCII to EBCDIC\n\
+  ibm       from ASCII to alternated EBCDIC\n\
+  block     pad newline-terminated records with spaces to cbs-size \n\
+  unblock   replace trailing spaces in cbs-size records with newline\n\
+  lcase     change uppercase to lowercase\n\
+  ucase     change lowercase to uppercase\n\
+  swab      swap every pair of input bytes\n\
+  noerror   continue after read errors\n\
+  sync      pad every input block with NULs to ibs-size\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index 7b77925..a4ef19d 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -185,7 +185,7 @@ main (argc, argv)
          add_excluded_fs_type (optarg);
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -196,7 +196,7 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (optind != argc)
     {
@@ -475,12 +475,31 @@ excluded_fstype (fstype)
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-Usage: %s [-aikPv] [-t fstype] [-x fstype] [--all] [--inodes]\n\
-\t[--type=fstype] [--exclude-type=fstype] [--kilobytes] [--portability]\n\
-\t[--help] [--version] [path...]\n",
+Usage: %s [OPTION] [PATH]...\n\
+\n",
           program_name);
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -a, --all                 include filesystems having 0 blocks\n\
+  -i, --inodes              list inode information instead of block usage\n\
+  -k, --kilobytes           use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
+  -t, --type TYPE           limit the listing to TYPE filesystems type\n\
+  -x, --exclude-type TYPE   limit the listing to not TYPE filesystems type\n\
+  -v                        (ignored)\n\
+  -P, --portability         use the POSIX output format\n\
+      --help                provide this help\n\
+      --version             show program version\n\
+\n\
+If no PATHs are given, list all currently mounted filesystems.\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index 5f538ec..89bc127 100644 (file)
--- a/src/du.c
+++ b/src/du.c
@@ -191,19 +191,38 @@ static struct option const long_options[] =
 };
 
 static void
-usage (reason)
+usage (reason, status)
      char *reason;
+     int status;
 {
   if (reason != NULL)
     fprintf (stderr, "%s: %s\n", program_name, reason);
 
   fprintf (stderr, "\
-Usage: %s [-abcklsxDLS] [--all] [--total] [--count-links] [--summarize]\n\
-       [--bytes] [--kilobytes] [--one-file-system] [--separate-dirs]\n\
-       [--dereference] [--dereference-args] [--help] [--version] [path...]\n",
+Usage: %s [OPTION]... [PATH]...\n\
+\n",
           program_name);
 
-  exit (2);
+  if (status == 0)
+    fprintf (stderr, "\
+  -a, --all                write counts for all files, not just directories\n\
+  -b, --bytes              print size in bytes\n\
+  -c, --total              produce a grand total\n\
+  -k, --kilobytes          use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
+  -l, --count-links        count sizes many times if hard linked\n\
+  -s, --summarize          display only a total for each argument\n\
+  -x, --one-file-system    skip directories on different filesystems\n\
+  -D, --dereference-args   dereference PATHs when symbolic link\n\
+  -L, --dereference        dereference all symbolic links\n\
+  -S, --separate-dirs      do not include size of subdirectories\n\
+      --help               provide this help\n\
+      --version            show program version\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
 \f
 void
@@ -266,7 +285,7 @@ main (argc, argv)
          break;
 
        default:
-         usage ((char *) 0);
+         usage ((char *) 0, 2);
        }
     }
 
@@ -277,10 +296,10 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage (NULL);
+    usage (NULL, 0);
 
   if (opt_all && opt_summarize_only)
-    usage ("cannot both summarize and show all entries");
+    usage ("cannot both summarize and show all entries", 2);
 
   /* Initialize the hash structure for inode numbers.  */
   hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
index 0756200..2c23868 100644 (file)
@@ -204,7 +204,7 @@ main (argc, argv)
          owner_name = optarg;
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -215,13 +215,13 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   /* Check for invalid combinations of arguments. */
   if ((dir_arg && strip_files)
       || (optind == argc)
       || (optind == argc - 1 && !dir_arg))
-    usage ();
+    usage (1);
 
   if (symbolic_mode)
     {
@@ -255,7 +255,7 @@ main (argc, argv)
       else
        {
          if (!isdir (argv[argc - 1]))
-           usage ();
+           usage (1);
          for (; optind < argc - 1; ++optind)
            {
              errors |= install_file_in_dir (argv[optind], argv[argc - 1]);
@@ -537,15 +537,30 @@ isnumber (str)
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
    fprintf (stderr, "\
-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] [--group=group]\n\
-       [--help] [--version] [--mode=mode] [--owner=owner]\n",
+Usage: %s [OPTION]... SOURCE DEST           (1st format)\n\
+  or:  %s [OPTION]... SOURCE... DIRECTORY   (2nd format)\n\
+  or:  %s [OPTION]... DIRECTORY...          (3nd format)\n\
+\n",
            program_name, program_name, program_name);
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -c                  (ignored)\n\
+  -d, --directory     create [leading] directories, mandatory for 3rd format\n\
+  -g, --group GROUP   set group ownership, instead of process' current group\n\
+  -m, --mode MODE     set permission mode (as in chmod), instead of 0755\n\
+  -o, --owner OWNER   set ownership (super-user only)\n\
+  -s, --strip         strip symbol tables, only for 1st and 2nd formats\n\
+      --help          provide this help\n\
+      --version       show program version\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index 8e96eb8..05137f9 100644 (file)
--- a/src/ln.c
+++ b/src/ln.c
@@ -104,7 +104,7 @@ static int show_help;
 /* If non-zero, print the version on standard output and exit.  */
 static int show_version;
 
-static struct option const long_options[] = 
+static struct option const long_options[] =
 {
   {"backup", no_argument, NULL, 'b'},
   {"directory", no_argument, &hard_dir_link, 1},
@@ -178,7 +178,7 @@ main (argc, argv)
          version = optarg;
          break;
        default:
-         usage ();
+         usage (1);
          break;
        }
     }
@@ -190,10 +190,10 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (optind == argc)
-    usage ();
+    usage (1);
 
   if (make_backups)
     backup_type = get_version (version);
@@ -324,7 +324,7 @@ do_link (source, dest)
       error (0, errno, "%s", dest);
       return 1;
     }
-       
+
   if (verbose)
     printf ("%s -> %s\n", source, dest);
 
@@ -350,16 +350,38 @@ do_link (source, dest)
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-Usage: %s [options] source [dest]\n\
-       %s [options] source... directory\n\
-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] [--help] [--version]\n",
+Usage: %s [OPTION]... SOURCE [DEST]\n\
+  or:  %s [OPTION]... SOURCE... DIRECTORY\n\
+\n",
           program_name, program_name);
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -b, --backup                 make backups for removed files\n\
+  -d, -F, --directory          hard link directories (super-user only)\n\
+  -f, --force                  remove existing destinations\n\
+  -i, --interactive            prompt whether to remove destinations\n\
+  -s, --symbolic               make symbolic links, instead of hard links\n\
+  -v, --verbose                print name of each file before linking\n\
+  -S, --suffix SUFFIX          override the usual backup suffix\n\
+  -V, --version-control WORD   override the usual version control\n\
+      --help                   provide this help\n\
+      --version                show program version\n\
+\n\
+The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX.  The\n\
+version control may be set with VERSION_CONTROL, values are:\n\
+\n\
+  t, numbered     make numbered backups\n\
+  nil, existing   numbered if numbered backups exist, simple otherwise\n\
+  never, simple   always make simple backups  \n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index 9db6174..6082408 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -465,7 +465,7 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   format_needs_stat = sort_type == sort_time || sort_type == sort_size
     || format == long_format
@@ -615,16 +615,16 @@ decode_switches (argc, argv)
          all_files = 1;
          really_all_files = 1;
          break;
-         
+
        case 'b':
          quote_funny_chars = 1;
          qmark_funny_chars = 0;
          break;
-         
+
        case 'c':
          time_type = time_ctime;
          break;
-         
+
        case 'd':
          immediate_dirs = 1;
          break;
@@ -647,106 +647,106 @@ decode_switches (argc, argv)
        case 'i':
          print_inode = 1;
          break;
-         
+
        case 'k':
          kilobyte_blocks = 1;
          break;
-         
+
        case 'l':
          format = long_format;
          break;
-         
+
        case 'm':
          format = with_commas;
          break;
-         
+
        case 'n':
          numeric_users = 1;
          break;
-         
+
        case 'p':
          indicator_style = not_programs;
          break;
-         
+
        case 'q':
          qmark_funny_chars = 1;
          quote_funny_chars = 0;
          break;
-         
+
        case 'r':
          sort_reverse = 1;
          break;
-         
+
        case 's':
          print_block_size = 1;
          break;
-         
+
        case 't':
          sort_type = sort_time;
          break;
-         
+
        case 'u':
          time_type = time_atime;
          break;
-         
+
        case 'w':
          line_length = atoi (optarg);
          if (line_length < 1)
            error (1, 0, "invalid line width: %s", optarg);
          break;
-         
+
        case 'x':
          format = horizontal;
          break;
-         
+
        case 'A':
          all_files = 1;
          break;
-         
+
        case 'B':
          add_ignore_pattern ("*~");
          add_ignore_pattern (".*~");
          break;
-         
+
        case 'C':
          format = many_per_line;
          break;
-         
+
        case 'F':
          indicator_style = all;
          break;
-         
+
        case 'G':               /* inhibit display of group info */
          inhibit_group = 1;
          break;
-         
+
        case 'I':
          add_ignore_pattern (optarg);
          break;
-         
+
        case 'L':
          trace_links = 1;
          break;
-         
+
        case 'N':
          quote_funny_chars = 0;
          qmark_funny_chars = 0;
          break;
-         
+
        case 'Q':
          quote_as_string = 1;
          quote_funny_chars = 1;
          qmark_funny_chars = 0;
          break;
-         
+
        case 'R':
          trace_dirs = 1;
          break;
-         
+
        case 'S':
          sort_type = sort_size;
          break;
-         
+
        case 'T':
          tabsize = atoi (optarg);
          if (tabsize < 1)
@@ -770,7 +770,7 @@ decode_switches (argc, argv)
          if (i < 0)
            {
              invalid_arg ("sort type", optarg, i);
-             usage ();
+             usage (1);
            }
          sort_type = sort_types[i];
          break;
@@ -780,7 +780,7 @@ decode_switches (argc, argv)
          if (i < 0)
            {
              invalid_arg ("time type", optarg, i);
-             usage ();
+             usage (1);
            }
          time_type = time_types[i];
          break;
@@ -790,13 +790,13 @@ decode_switches (argc, argv)
          if (i < 0)
            {
              invalid_arg ("format type", optarg, i);
-             usage ();
+             usage (1);
            }
          format = formats[i];
          break;
-         
+
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -1877,19 +1877,64 @@ attach (dest, dirname, name)
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-Usage: %s [-abcdgiklmnpqrstuxABCFGLNQRSUX1] [-w cols] [-T cols] [-I pattern]\n\
-       [--all] [--escape] [--directory] [--inode] [--kilobytes] [--literal]\n\
-       [--numeric-uid-gid] [--hide-control-chars] [--reverse] [--size]\n\
-       [--width=cols] [--tabsize=cols] [--almost-all] [--ignore-backups]\n",
+Usage: %s [OPTION]... [PATH]...\n\
+\n",
           program_name);
-  fprintf (stderr, "\
-       [--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]\n\
-       [--help] [--version] [path...]\n");
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -a, --all                  do not hide entries starting with .\n\
+  -b, --escape               print octal escapes for nongraphic characters\n\
+  -c                         sort by change time, list change time if -l\n\
+  -d, --directory            list directory entries, instead of contents\n\
+  -f                         do not sort, enable -aU, disable -lst\n\
+  -g                         (ignored)\n\
+  -i, --inode                print index number of each file\n\
+  -k, --kilobytes            use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
+  -l                         make a long listing, with many informations\n\
+  -m                         fill width with a comma separated list of entries\n\
+  -n, --numeric-uid-gid      list numeric UIDs and GIDs, instead of names\n\
+  -p                         append a character for typing each entry\n\
+  -q, --hide-control-chars   print ? instead of non graphic characters\n\
+  -r, --reverse              reverse order while sorting\n\
+  -s, --size                 print block size of each file\n\
+  -t                         sort by modification time, list mod time if -l\n\
+  -u                         sort by last access time, list access time if -l\n\
+  -w, --width COLS           assume screen width, instead of current value\n\
+  -x                         list entries by lines, instead of by columns\n\
+  -A, --almost-all           hide only implied . and ..\n\
+  -B, --ignore-backups       hide implied entries ending with ~\n\
+  -C                         list entries by columns\n\
+  -F, --classify             append a character for typing each entry\n\
+  -G, --no-group             inhibit display of group information\n\
+  -I, --ignore PATTERN       hide implied entries matching shell PATTERN\n\
+  -L, --dereference          list entries pointed to by symbolic links\n\
+  -N, --literal              do not quote entry names\n\
+  -Q, --quote-name           enclose entry names in double quotes\n\
+  -R, --recursive            list subdirectories recursively\n\
+  -S                         sort by file size\n\
+  -T, --tabsize COLS         assume tab stops at each COLS, instead of 8\n\
+  -U                         do not sort and list entries in directory order\n\
+  -X                         sort alphabetically by entry extension\n\
+  -1                         list one file per line\n\
+      --full-time            list both full date and full time\n\
+      --help                 provide this help\n\
+      --format WORD          across -x, commas -m, horizontal -x, long -l,\n\
+                               single-column -1, verbose -l, vertical -C\n\
+      --sort WORD            ctime -c, extension -X, none -U, size -S,\n\
+                               status -c, time -t\n\
+      --time WORD            atime -u, access -u, use -u\n\
+      --version              show program version\n\
+\n\
+Sort entries alphabetically if none of -cftuSUX nor --sort.\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index 1167c1a..5ed40b8 100644 (file)
@@ -99,7 +99,7 @@ main (argc, argv)
          symbolic_mode = optarg;
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -110,10 +110,10 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (optind == argc)
-    usage ();
+    usage (1);
 
   newmode = 0777 & ~umask (0);
   parent_mode = newmode | 0300;        /* u+wx */
@@ -142,11 +142,25 @@ main (argc, argv)
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-Usage: %s [-p] [-m mode] [--parents] [--mode=mode]\n\
-       [--help] [--version] dir...\n", program_name);
-  exit (1);
+Usage: %s [OPTION] DIRECTORY...\n\
+\n",
+          program_name);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -p, --parents     no error if existing, make parent directories as needed\n\
+  -m, --mode MODE   set permission mode (as in chmod), not 0777 - umask\n\
+      --help        provide this help\n\
+      --version     show program version\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
 
index c15f740..efdf883 100644 (file)
@@ -88,7 +88,7 @@ main (argc, argv)
          symbolic_mode = optarg;
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -99,10 +99,10 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (optind == argc)
-    usage ();
+    usage (1);
 
   newmode = 0666 & ~umask (0);
   if (symbolic_mode)
@@ -130,11 +130,24 @@ main (argc, argv)
 
 #ifdef S_ISFIFO
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-Usage: %s [-m mode] [--mode=mode] [--help] [--version] path...\n",
+Usage: %s [OPTION] PATH...\n\
+\n",
           program_name);
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -m, --mode MODE   set permission mode (as in chmod), not 0666 - umask\n\
+      --help        provide this help\n\
+      --version     show program version\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
 #endif
index 7024351..f9a614a 100644 (file)
@@ -89,7 +89,7 @@ main (argc, argv)
          symbolic_mode = optarg;
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -100,7 +100,7 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   newmode = 0666 & ~umask (0);
   if (symbolic_mode)
@@ -114,7 +114,7 @@ main (argc, argv)
     }
 
   if (argc - optind != 2 && argc - optind != 4)
-    usage ();
+    usage (1);
 
   /* Only check the first character, to allow mnemonic usage like
      `mknod /dev/rst0 character 18 0'. */
@@ -126,7 +126,7 @@ main (argc, argv)
       error (4, 0, "block special files not supported");
 #else
       if (argc - optind != 4)
-       usage ();
+       usage (1);
       if (mknod (argv[optind], newmode | S_IFBLK,
                 makedev (atoi (argv[optind + 2]), atoi (argv[optind + 3]))))
        error (1, errno, "%s", argv[optind]);
@@ -139,7 +139,7 @@ main (argc, argv)
       error (4, 0, "character special files not supported");
 #else
       if (argc - optind != 4)
-       usage ();
+       usage (1);
       if (mknod (argv[optind], newmode | S_IFCHR,
                 makedev (atoi (argv[optind + 2]), atoi (argv[optind + 3]))))
        error (1, errno, "%s", argv[optind]);
@@ -151,27 +151,43 @@ main (argc, argv)
       error (4, 0, "fifo files not supported");
 #else
       if (argc - optind != 2)
-       usage ();
+       usage (1);
       if (mkfifo (argv[optind], newmode))
        error (1, errno, "%s", argv[optind]);
 #endif
       break;
 
     default:
-      usage ();
+      usage (1);
     }
 
   exit (0);
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-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);
+Usage: %s [OPTION]... PATH TYPE [MAJOR MINOR]\n\
+\n",
+          program_name);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -m, --mode MODE   set permission mode (as in chmod), not 0666 - umask\n\
+      --help        provide this help\n\
+      --version     show program version\n\
+\n\
+MAJOR MINOR are forbidden for TYPE p, mandatory otherwise.  TYPE may be:\n\
+\n\
+  b      create a block (buffered) special file\n\
+  c, u   create a character (unbuffered) special file   \n\
+  p      create a FIFO\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index a5d22eb..c785bf3 100644 (file)
--- a/src/mv.c
+++ b/src/mv.c
 
    -i, --interactive   Require confirmation from the user before
                        performing any move that would destroy an
-                       existing file. 
+                       existing file.
 
    -u, --update                Do not move a nondirectory that has an
                        existing destination with the same or newer
-                       modification time.  
+                       modification time.
 
    -v, --verbose               List the name of each file as it is moved, and
-                       the name it is moved to. 
+                       the name it is moved to.
 
    -b, --backup
    -S, --suffix
@@ -170,7 +170,7 @@ main (argc, argv)
          version = optarg;
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -181,10 +181,10 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (argc < optind + 2)
-    usage ();
+    usage (1);
 
   if (make_backups)
     backup_type = get_version (version);
@@ -335,7 +335,7 @@ do_move (source, dest)
 
   if (copy_reg (source, dest))
     goto un_backup;
-  
+
   if (unlink (source))
     {
       error (0, errno, "cannot remove `%s'", source);
@@ -364,14 +364,14 @@ copy_reg (source, dest)
   int ofd;
   char buf[1024 * 8];
   int len;                     /* Number of bytes read into `buf'. */
-  
+
   if (!S_ISREG (source_stats.st_mode))
     {
       error (0, 0, "cannot move `%s' across filesystems: Not a regular file",
             source);
       return 1;
     }
-  
+
   if (unlink (dest) && errno != ENOENT)
     {
       error (0, errno, "cannot remove `%s'", dest);
@@ -396,7 +396,7 @@ copy_reg (source, dest)
     {
       int wrote = 0;
       char *bp = buf;
-      
+
       do
        {
          wrote = write (ofd, bp, len);
@@ -432,7 +432,7 @@ copy_reg (source, dest)
       error (0, errno, "%s", dest);
       return 1;
     }
-  
+
   /* chown turns off set[ug]id bits for non-root,
      so do the chmod last.  */
 
@@ -468,16 +468,37 @@ copy_reg (source, dest)
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-Usage: %s [options] source dest\n\
-       %s [options] source... directory\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\
-       [--help] [--version]\n",
+Usage: %s [OPTION]... SOURCE DEST\n\
+  or:  %s [OPTION]... SOURCE... DIRECTORY\n\
+\n",
           program_name, program_name);
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -b, --backup                 make backup before removal\n\
+  -f, --force                  remove existing destinations, never prompt\n\
+  -i, --interactive            prompt before overwrite\n\
+  -u, --update                 move only older or brand new files\n\
+  -v, --verbose                explain what is being done\n\
+  -S, --suffix SUFFIX          override the usual backup suffix\n\
+  -V, --version-control WORD   override the usual version control\n\
+      --help                   provide this help\n\
+      --version                show program version\n\
+\n\
+The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX.  The\n\
+version control may be set with VERSION_CONTROL, values are:\n\
+\n\
+  t, numbered     make numbered backups\n\
+  nil, existing   numbered if numbered backups exist, simple otherwise\n\
+  never, simple   always make simple backups  \n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index b20950f..2b17e64 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -145,7 +145,7 @@ main (argc, argv)
          verbose = 1;
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -156,14 +156,14 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (optind == argc)
     {
       if (ignore_missing_files)
        exit (0);
       else
-       usage ();
+       usage (1);
     }
 
   stdin_tty = isatty (0);
@@ -526,11 +526,27 @@ is the same file as\n", program_name, pathname);
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   fprintf (stderr, "\
-Usage: %s [-dfirvR] [--directory] [--force] [--interactive] [--recursive]\n\
-       [--verbose] [--help] [--version] path...\n",
+Usage: %s [OPTION]... PATH...\n\
+\n",
           program_name);
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -d, --directory       unlink directory, even if non-empty (super-user only)\n\
+  -f, --force           ignore nonexistent files, never prompt\n\
+  -i, --interactive     prompt before any removal\n\
+  -v, --verbose         explain what is being done\n\
+  -r, -R, --recursive   remove the contents of directories recursively\n\
+      --help            provide this help\n\
+      --version         show program version\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index ac4c88c..07ad705 100644 (file)
@@ -87,7 +87,7 @@ main (argc, argv)
          empty_paths = 1;
          break;
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -98,10 +98,10 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (optind == argc)
-    usage ();
+    usage (1);
 
   for (; optind < argc; ++optind)
     {
@@ -144,9 +144,23 @@ remove_parents (path)
 }
 
 static void
-usage ()
+usage (status)
+     int status;
 {
-  fprintf (stderr, "Usage: %s [-p] [--parents] [--help] [--version] dir...\n",
+  fprintf (stderr, "\
+Usage: %s [OPTION]... DIRECTORY...\n\
+\n",
           program_name);
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -p, --parents   remove explicit parent directories if being emptied\n\
+      --help      provide this help\n\
+      --version   show program version\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }
index dc1d06f..35b3d8f 100644 (file)
@@ -24,7 +24,7 @@
    -r, --file=FILE             Use the time and date of reference file FILE.
    -t TIME                     Specify time and date in the form
                                `MMDDhhmm[[CC]YY][.ss]'.
-   
+
    If no options are given, -am is the default, using the current time.
    The -r, -t, and -d options are mutually exclusive.  If a file does not
    exist, create it unless -c is given.
@@ -194,13 +194,13 @@ main (argc, argv)
          if (i < 0)
            {
              invalid_arg ("time selector", optarg, i);
-             usage ();
+             usage (1);
            }
          change_times |= time_masks[i];
          break;
 
        default:
-         usage ();
+         usage (1);
        }
     }
 
@@ -211,7 +211,7 @@ main (argc, argv)
     }
 
   if (show_help)
-    usage ();
+    usage (0);
 
   if (change_times == 0)
     change_times = CH_ATIME | CH_MTIME;
@@ -220,7 +220,7 @@ main (argc, argv)
       || (posix_date && flexible_date))
     {
       error (0, 0, "cannot specify times from more than one source");
-      usage ();
+      usage (1);
     }
 
   if (use_ref)
@@ -250,7 +250,7 @@ main (argc, argv)
   if (optind == argc)
     {
       error (0, 0, "file arguments missing");
-      usage ();
+      usage (1);
     }
 
   for (; optind < argc; ++optind)
@@ -304,7 +304,7 @@ touch (file)
        {
          error (0, errno, "%s", file);
          return 1;
-       }       
+       }
     }
 
   if (amtime_now)
@@ -337,7 +337,7 @@ touch (file)
 
       status = utime (file, &utb);
     }
-  
+
   if (status)
     {
       error (0, errno, "%s", file);
@@ -376,12 +376,32 @@ utime_now (file, filesize)
 #endif
 
 static void
-usage ()
+usage (status)
+     int status;
 {
   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] [--help] [--version] file...\n",
+Usage: %s [OPTION]... FILE...\n\
+\n",
           program_name);
-  exit (1);
+
+  if (status == 0)
+    fprintf (stderr, "\
+  -a                     change the access time only\n\
+  -c                     do not create files that do not exist\n\
+  -d, --date STRING      parse STRING and use it, instead of current time\n\
+  -f                     (ignored)\n\
+  -m                     change the modification time only\n\
+  -r, --file REFERENCE   use this file's times, instead of current time\n\
+  -t STAMP               use MMDDhhmm[[CC]YY][.ss], instead of current time\n\
+      --help             provide this help\n\
+      --time WORD        access -a, atime -a, mtime -m, modify -m, use -a\n\
+      --version          show program version\n\
+\n\
+STAMP may be used without -t if none of -drt, nor --, are used.\n");
+
+  else
+    fprintf (stderr, "Try `%s --help' for more information.\n",
+            program_name);
+
+  exit (status);
 }