merge with 1.8.1i
authorJim Meyering <jim@meyering.net>
Tue, 26 Oct 1993 00:11:14 +0000 (00:11 +0000)
committerJim Meyering <jim@meyering.net>
Tue, 26 Oct 1993 00:11:14 +0000 (00:11 +0000)
20 files changed:
old/sh-utils/ChangeLog
src/basename.c
src/date.c
src/dirname.c
src/echo.c
src/env.c
src/expr.c
src/id.c
src/logname.c
src/nice.c
src/pathchk.c
src/printf.c
src/sleep.c
src/stty.c
src/su.c
src/tee.c
src/test.c
src/tty.c
src/uname.c
src/who.c

index 4ba2951..3fcd6be 100644 (file)
@@ -1,5 +1,13 @@
+Mon Oct 25 19:22:58 EDT 1993
+
+       * stty.c (main, integer_arg): Don't just call error(1,... about
+       improper usage.  Call `error (0,...' them usage (1).
+
 Sun Oct 24 14:10:23 1993  Jim Meyering  (meyering@comco.com)
 
+       * test.c [member]: Don't try to cast index return value to an int.
+       That can lose on systems with 64-bit pointers.
+
        * long-options.c: Save and restore optind, too.
        * long-options.h: New file.
        * long-options.c, echo.c, expr.c, printf.c, test.c, yes.c:
index 6c8e7fe..9b7ccae 100644 (file)
@@ -68,22 +68,18 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... PATH [SUFFIX]\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... PATH [SUFFIX]\n", program_name);
+      printf ("\
 \n\
   --help      display this help and exit\n\
   --version   output version information and exit\n\
 ");
-
+    }
   exit (status);
 }
 
index 9e5605c..08998b2 100644 (file)
@@ -224,20 +224,17 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [+FORMAT] [MMDDhhmm[[CC]YY][.ss]]\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
     {
+      printf ("Usage: %s [OPTION]... [+FORMAT] [MMDDhhmm[[CC]YY][.ss]]\n",
+             program_name);
       printf ("\
 \n\
-  -d, --date STRING        display time described by STRING, not `now'\n\
-  -s, --set STRING         set time described by STRING\n\
+  -d, --date=STRING        display time described by STRING, not `now'\n\
+  -s, --set=STRING         set time described by STRING\n\
   -u, --uct, --universal   print or set Universal Coordinated Time\n\
       --help               display this help and exit\n\
       --version            output version information and exit\n\
@@ -278,6 +275,5 @@ FORMAT controls the output.  Interpreted sequences are:\n\
   %%y   last two digits of year (00..99)\n\
 ");
     }
-
   exit (status);
 }
index a40c826..8027135 100644 (file)
@@ -57,22 +57,18 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... PATH\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... PATH\n", program_name);
+      printf ("\
 \n\
   --help      display this help and exit\n\
   --version   output version information and exit\n\
 ");
-
+    }
   exit (status);
 }
 
index 4a2f673..65864ec 100644 (file)
@@ -76,17 +76,13 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [STRING]...\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... [STRING]...\n", program_name);
+      printf ("\
 \n\
   -n              do not output the trailing newline\n\
   -e              (unused)\n\
@@ -107,7 +103,7 @@ Without -E, the following sequences are recognized and interpolated:\n\
   \\t     horizontal tab\n\
   \\v     vertical tab\n\
 ");
-
+    }
   exit (status);
 }
 
index 2fb0d7e..743cf5d 100644 (file)
--- a/src/env.c
+++ b/src/env.c
@@ -195,25 +195,22 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]\n",
+             program_name);
+      printf ("\
 \n\
-  -u, --unset NAME           remove variable from the environment\n\
+  -u, --unset=NAME           remove variable from the environment\n\
   -i, --ignore-environment   start with an empty environment\n\
       --help                 display this help and exit\n\
       --version              output version information and exit\n\
 \n\
 A mere - implies -i.  If no COMMAND, print the resulting environment.\n\
 ");
-
+    }
   exit (status);
 }
index 22e7e83..26c4ffa 100644 (file)
@@ -46,7 +46,7 @@
 
 #include "system.h"
 #include "version.h"
-#include "long-option.h"
+#include "long-options.h"
 
 #if !defined (isascii) || defined (STDC_HEADERS)
 #undef isascii
@@ -110,18 +110,17 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s EXPRESSION\n\
-  or:  %s OPTION\n\
-",
-          program_name, program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
     {
       printf ("\
+Usage: %s EXPRESSION\n\
+  or:  %s OPTION\n\
+",
+             program_name, program_name);
+      printf ("\
 \n\
   --help      display this help and exit\n\
   --version   output version information and exit\n\
@@ -166,7 +165,6 @@ Pattern matches return the string matched between \\( and \\) or null; if\n\
 \\( and \\) are not used, they return the number of characters matched or 0.\n\
 ");
     }
-
   exit (status);
 }
 
index 3f2b32c..a43921b 100644 (file)
--- a/src/id.c
+++ b/src/id.c
@@ -363,17 +363,13 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [USERNAME]\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... [USERNAME]\n", program_name);
+      printf ("\
 \n\
   -g, --group     print only the group ID\n\
   -n, --name      print a name instead of a number, for -ugG\n\
@@ -385,6 +381,6 @@ Usage: %s [OPTION]... [USERNAME]\n\
 \n\
 Without any OPTION, print some useful set of identified information.\n\
 ");
-
+    }
   exit (status);
 }
index f8fcf38..86f648c 100644 (file)
@@ -53,22 +53,18 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]...\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]...\n", program_name);
+      printf ("\
 \n\
   --help      display this help and exit\n\
   --version   output version information and exit\n\
 ");
-
+    }
   exit (status);
 }
 
index 616a8f3..94f750e 100644 (file)
@@ -174,26 +174,22 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [COMMAND [ARG]...]\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... [COMMAND [ARG]...]\n", program_name);
+      printf ("\
 \n\
   -ADJUST                   increment priority by ADJUST first\n\
-  -n, --adjustment ADJUST   same as -ADJUST\n\
+  -n, --adjustment=ADJUST   same as -ADJUST\n\
       --help                display this help and exit\n\
       --version             output version information and exit\n\
 \n\
 With no COMMAND, print the current scheduling priority.  ADJUST is 10\n\
 by default.  Range goes from -20 (highest priority) to 19 (lowest).\n\
 ");
-
+    }
   exit (status);
 }
index afb663a..e98b75e 100644 (file)
@@ -361,22 +361,18 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... PATH...\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... PATH...\n", program_name);
+      printf ("\
 \n\
   -p, --portability   check for all POSIX systems, not only this one\n\
       --help          display this help and exit\n\
       --version       output version information and exit\n\
 ");
-
+    }
   exit (status);
 }
index c6d476b..43cc0de 100644 (file)
@@ -61,7 +61,7 @@
 
 #include "system.h"
 #include "version.h"
-#include "long-option.h"
+#include "long-options.h"
 
 #if !defined (isascii) || defined (STDC_HEADERS)
 #undef isascii
@@ -104,18 +104,17 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s FORMAT [ARGUMENT]...\n\
-  or:  %s OPTION\n\
-",
-          program_name, program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("\
+Usage: %s FORMAT [ARGUMENT]...\n\
+  or:  %s OPTION\n\
+",
+             program_name, program_name);
+      printf ("\
 \n\
   --help      display this help and exit\n\
   --version   output version information and exit\n\
@@ -141,7 +140,7 @@ FORMAT controls the output as in C printf.  Interpreted sequences are:\n\
 and all C format specifications ending with one of diouxXfeEgGcs, with\n\
 ARGUMENTs converted to proper type first.  Variable widths are handled.\n\
 ");
-
+    }
   exit (status);
 }
 
index a98ce9d..bf15f81 100644 (file)
@@ -57,24 +57,20 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... NUMBER[SUFFIX]\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... NUMBER[SUFFIX]\n", program_name);
+      printf ("\
 \n\
   --help      display this help and exit\n\
   --version   output version information and exit\n\
 \n\
 SUFFIX may be s for seconds, m for minutes, h for hours or d for days.\n\
 ");
-
+    }
   exit (status);
 }
 
index c4d0946..07307ff 100644 (file)
@@ -446,16 +446,12 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [SETTING]...\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
     {
+      printf ("Usage: %s [OPTION]... [SETTING]...\n", program_name);
       printf ("\
 \n\
   -a, --all       print all current settings in human-readable form\n\
@@ -619,7 +615,6 @@ settings, CHAR is taken literally, or coded as in ^c, 0x37, 0177 or\n\
 127; special values ^- or undef used to disable special characters.\n\
 ");
     }
-
   exit (status);
 }
 
@@ -675,7 +670,10 @@ done:;
   if (optind == argc)
     {
       if (optc == '?')
-       error (1, 0, "invalid argument `%s'", argv[--optind]);
+       {
+         error (0, 0, "invalid argument `%s'", argv[--optind]);
+         usage (1);
+       }
       display_settings (output_type, &mode);
       exit (0);
     }
@@ -700,7 +698,10 @@ done:;
            }
        }
       if (match_found == 0 && reversed)
-       error (1, 0, "invalid argument `%s'", --argv[optind]);
+       {
+         error (0, 0, "invalid argument `%s'", --argv[optind]);
+         usage (1);
+       }
       if (match_found == 0)
        {
          for (i = 0; control_info[i].name != NULL; ++i)
@@ -708,7 +709,10 @@ done:;
              if (!strcmp (argv[optind], control_info[i].name))
                {
                  if (optind == argc - 1)
-                   error (1, 0, "missing argument to `%s'", argv[optind]);
+                   {
+                     error (0, 0, "missing argument to `%s'", argv[optind]);
+                     usage (1);
+                   }
                  match_found = 1;
                  ++optind;
                  set_control_char (&control_info[i], argv[optind], &mode);
@@ -721,14 +725,20 @@ done:;
          if (!strcmp (argv[optind], "ispeed"))
            {
              if (optind == argc - 1)
-               error (1, 0, "missing argument to `%s'", argv[optind]);
+               {
+                 error (0, 0, "missing argument to `%s'", argv[optind]);
+                 usage (1);
+               }
              ++optind;
              set_speed (input_speed, argv[optind], &mode);
            }
          else if (!strcmp (argv[optind], "ospeed"))
            {
              if (optind == argc - 1)
-               error (1, 0, "missing argument to `%s'", argv[optind]);
+               {
+                 error (0, 0, "missing argument to `%s'", argv[optind]);
+                 usage (1);
+               }
              ++optind;
              set_speed (output_speed, argv[optind], &mode);
            }
@@ -736,7 +746,10 @@ done:;
          else if (!strcmp (argv[optind], "rows"))
            {
              if (optind == argc - 1)
-               error (1, 0, "missing argument to `%s'", argv[optind]);
+               {
+                 error (0, 0, "missing argument to `%s'", argv[optind]);
+                 usage (1);
+               }
              ++optind;
              set_window_size ((int) integer_arg (argv[optind]), -1);
            }
@@ -744,7 +757,10 @@ done:;
                   || !strcmp (argv[optind], "columns"))
            {
              if (optind == argc - 1)
-               error (1, 0, "missing argument to `%s'", argv[optind]);
+               {
+                 error (0, 0, "missing argument to `%s'", argv[optind]);
+                 usage (1);
+               }
              ++optind;
              set_window_size (-1, (int) integer_arg (argv[optind]));
            }
@@ -755,7 +771,10 @@ done:;
          else if (!strcmp (argv[optind], "line"))
            {
              if (optind == argc - 1)
-               error (1, 0, "missing argument to `%s'", argv[optind]);
+               {
+                 error (0, 0, "missing argument to `%s'", argv[optind]);
+                 usage (1);
+               }
              ++optind;
              mode.c_line = integer_arg (argv[optind]);
            }
@@ -765,7 +784,10 @@ done:;
          else if (string_to_baud (argv[optind]) != (speed_t) -1)
            set_speed (both_speeds, argv[optind], &mode);
          else if (recover_mode (argv[optind], &mode) == 0)
-           error (1, 0, "invalid argument `%s'", argv[optind]);
+           {
+             error (0, 0, "invalid argument `%s'", argv[optind]);
+             usage (1);
+           }
        }
       optind++;
     }
@@ -1479,6 +1501,9 @@ integer_arg (s)
     p--;
 
   if (*p)
-    error (1, 0, "invalid integer argument `%s'", s);
+    {
+      error (0, 0, "invalid integer argument `%s'", s);
+      usage (1);
+    }
   return value;
 }
index 7db31c1..7669aef 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -551,29 +551,25 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [-] [USER [ARG]...]\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... [-] [USER [ARG]...]\n", program_name);
+      printf ("\
 \n\
   -l, --login                  make the shell a login shell\n\
-  -c, --commmand COMMAND       pass a single COMMAND to the shell with -c\n\
+  -c, --commmand=COMMAND       pass a single COMMAND to the shell with -c\n\
   -f, --fast                   pass -f to the shell (for csh or tcsh)\n\
   -m, --preserve-environment   do not reset environment variables\n\
   -p                           same as -m\n\
-  -s, --shell SHELL            run SHELL if /etc/shells allows it\n\
+  -s, --shell=SHELL            run SHELL if /etc/shells allows it\n\
       --help                   display this help and exit\n\
       --version                output version information and exit\n\
 \n\
 A mere - implies -l.   If USER not given, assume root.\n\
 ");
-
+    }
   exit (status);
 }
index 66fccd9..4cfa93c 100644 (file)
--- a/src/tee.c
+++ b/src/tee.c
@@ -70,24 +70,20 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [FILE]...\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... [FILE]...\n", program_name);
+      printf ("\
 \n\
   -a, --append              append to the given FILEs, do not overwrite\n\
   -i, --ignore-interrupts   ignore interrupt signals\n\
       --help                display this help and exit\n\
       --version             output version information and exit\n\
 ");
-
+    }
   exit (status);
 }
 
index c3d5c54..a4fd543 100644 (file)
@@ -1008,25 +1008,24 @@ posixtest ()
 }
 
 #if defined (TEST_STANDALONE)
-#include "long-option.h"
+#include "long-options.h"
 
 static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s EXPRESSION\n\
-  or:  [ EXPRESSION ]\n\
-  or:  %s OPTION\n\
-",
-          program_name, program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
     {
       printf ("\
+Usage: %s EXPRESSION\n\
+  or:  [ EXPRESSION ]\n\
+  or:  %s OPTION\n\
+",
+             program_name, program_name);
+      printf ("\
 \n\
   --help      display this help and exit\n\
   --version   output version information and exit\n\
@@ -1087,7 +1086,6 @@ Beware that parentheses need to be escaped by backslashes for shells.\n\
 INTEGER may also be -l STRING, which evaluates to the length of STRING.\n\
 ");
     }
-
   exit (status);
 }
 #endif /* TEST_STANDALONE */
index 83e3512..4b7aaa0 100644 (file)
--- a/src/tty.c
+++ b/src/tty.c
@@ -123,22 +123,18 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]...\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]...\n", program_name);
+      printf ("\
 \n\
   -s, --silent, --quiet   print nothing, only return an exit status\n\
       --help              display this help and exit\n\
       --version           output version information and exit\n\
 ");
-
+    }
   exit (status);
 }
index 01b5f02..65fad1c 100644 (file)
@@ -188,17 +188,13 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]...\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]...\n", program_name);
+      printf ("\
 \n\
   -a, --all        print all information\n\
   -m, --machine    print the machine (hardware) type\n\
@@ -211,6 +207,6 @@ Usage: %s [OPTION]...\n\
 \n\
 Without any OPTION, assume -s.\n\
 ");
-
+    }
   exit (status);
 }
index 8b122c8..f01da1b 100644 (file)
--- a/src/who.c
+++ b/src/who.c
@@ -462,17 +462,13 @@ static void
 usage (status)
      int status;
 {
-  fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [ FILE | ARG1 ARG2 ]\n\
-",
-          program_name);
-
   if (status != 0)
     fprintf (stderr, "Try `%s --help' for more information.\n",
             program_name);
   else
-
-    printf ("\
+    {
+      printf ("Usage: %s [OPTION]... [ FILE | ARG1 ARG2 ]\n", program_name);
+      printf ("\
 \n\
   -H, --heading     print line of column headings\n\
   -T, -w, --mesg    add user's message status as +, - or ?\n\
@@ -488,6 +484,6 @@ Usage: %s [OPTION]... [ FILE | ARG1 ARG2 ]\n\
 If FILE not given, uses /etc/utmp.  /etc/wtmp as FILE is common.\n\
 If ARG1 ARG2 given, -m presumed: `am i' or `mom likes' are usual.\n\
 ");
-
+    }
   exit (status);
 }