bug-automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

--help and --version should exit with nonzero status on write failures


From: Paul Eggert
Subject: --help and --version should exit with nonzero status on write failures
Date: Wed, 02 Feb 2005 11:17:12 -0800

I noticed that Automake-related commands exit with status zero when
giving help or version output, even if there is a write failure.
That isn't right: they should exit with status zero only if they
successfully output the help or version information requested.

Here is a patch for the shell commands affected; these are higher
priority for me, as they are used by other programs like Automake.
I suspect that non-shell programs also need fixing, though.

In the patch below, I used "exit $?" rather than "exit" to work around
bugs in common shell implementations (e.g., Cygwin Bash 2.04).

2005-02-02  Paul Eggert  <address@hidden>

        * lib/depcomp: Exit with nonzero status if a write failure occurs
        with --help or --version option.
        * lib/elisp-comp: Likewise.
        * lib/gnupload: Likewise.
        * lib/install-sh: Likewise.
        * lib/missing: Likewise.
        * lib/mkinstalldirs: Likewise.

Index: lib/depcomp
===================================================================
RCS file: /cvs/automake/automake/lib/depcomp,v
retrieving revision 1.51
diff -p -u -r1.51 depcomp
--- lib/depcomp 31 May 2004 21:44:57 -0000      1.51
+++ lib/depcomp 2 Feb 2005 19:12:59 -0000
@@ -50,11 +50,11 @@ Environment variables:
 
 Report bugs to <address@hidden>.
 EOF
-    exit 0
+    exit $?
     ;;
   -v | --v*)
     echo "depcomp $scriptversion"
-    exit 0
+    exit $?
     ;;
 esac
 
Index: lib/elisp-comp
===================================================================
RCS file: /cvs/automake/automake/lib/elisp-comp,v
retrieving revision 1.11
diff -p -u -r1.11 elisp-comp
--- lib/elisp-comp      10 Sep 2004 18:47:08 -0000      1.11
+++ lib/elisp-comp      2 Feb 2005 19:12:59 -0000
@@ -47,11 +47,11 @@ they require or load-library one another
 
 Report bugs to <address@hidden>.
 EOF
-    exit 0
+    exit $?
     ;;
   -v | --v*)
     echo "elisp-comp $scriptversion"
-    exit 0
+    exit $?
     ;;
 esac
 
Index: lib/gnupload
===================================================================
RCS file: /cvs/automake/automake/lib/gnupload,v
retrieving revision 1.4
diff -p -u -r1.4 gnupload
--- lib/gnupload        29 Feb 2004 22:28:39 -0000      1.4
+++ lib/gnupload        2 Feb 2005 19:12:59 -0000
@@ -55,7 +55,7 @@ while test -n "$1"; do
   case $1 in
     --help)
       echo "$usage"
-      exit 0
+      exit $?
       ;;
     --to)
       if test -z "$2"; then
@@ -77,7 +77,7 @@ while test -n "$1"; do
       ;;
     --version)
       echo "gnupload $scriptversion"
-      exit 0
+      exit $?
       ;;
     -*)
       echo "$0: Unknown option \`$1', try \`$0 --help'" 1>&2
Index: lib/install-sh
===================================================================
RCS file: /cvs/automake/automake/lib/install-sh,v
retrieving revision 1.22
diff -p -u -r1.22 install-sh
--- lib/install-sh      17 Dec 2004 23:25:09 -0000      1.22
+++ lib/install-sh      2 Feb 2005 19:12:59 -0000
@@ -109,7 +109,7 @@ while test -n "$1"; do
         shift
         continue;;
 
-    --help) echo "$usage"; exit 0;;
+    --help) echo "$usage"; exit $?;;
 
     -m) chmodcmd="$chmodprog $2"
         shift
@@ -134,7 +134,7 @@ while test -n "$1"; do
        shift
        continue;;
 
-    --version) echo "$0 $scriptversion"; exit 0;;
+    --version) echo "$0 $scriptversion"; exit $?;;
 
     *)  # When -d is used, all remaining arguments are directories to create.
        # When -t is used, the destination is already specified.
Index: lib/missing
===================================================================
RCS file: /cvs/automake/automake/lib/missing,v
retrieving revision 1.25
diff -p -u -r1.25 missing
--- lib/missing 7 Sep 2004 06:25:31 -0000       1.25
+++ lib/missing 2 Feb 2005 19:12:59 -0000
@@ -87,12 +87,12 @@ Supported PROGRAM values:
   yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
 
 Send bug reports to <address@hidden>."
-    exit 0
+    exit $?
     ;;
 
   -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
     echo "missing $scriptversion (GNU Automake)"
-    exit 0
+    exit $?
     ;;
 
   -*)
Index: lib/mkinstalldirs
===================================================================
RCS file: /cvs/automake/automake/lib/mkinstalldirs,v
retrieving revision 1.16
diff -p -u -r1.16 mkinstalldirs
--- lib/mkinstalldirs   15 Feb 2004 21:14:23 -0000      1.16
+++ lib/mkinstalldirs   2 Feb 2005 19:12:59 -0000
@@ -27,7 +27,7 @@ while test $# -gt 0 ; do
   case $1 in
     -h | --help | --h*)         # -h for help
       echo "$usage"
-      exit 0
+      exit $?
       ;;
     -m)                         # -m PERM arg
       shift
@@ -37,7 +37,7 @@ while test $# -gt 0 ; do
       ;;
     --version)
       echo "$0 $scriptversion"
-      exit 0
+      exit $?
       ;;
     --)                         # stop option processing
       shift




reply via email to

[Prev in Thread] Current Thread [Next in Thread]