]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/Autom4te/General.pm (END): Rewrite exit code processing.
authorAlexandre Duret-Lutz <adl@gnu.org>
Fri, 23 May 2003 18:16:56 +0000 (18:16 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Fri, 23 May 2003 18:16:56 +0000 (18:16 +0000)
Do not call `_exit()', simply modify `$?'.
(xsystem): Reset $! before running system, and check it afterward.
* tests/tools.at (autoupdating AC_PREREQ): Expect exit status
63 for version mismatches.

ChangeLog
lib/Autom4te/General.pm
tests/tools.at

index 9905ea283c5f0637dd6297cc5af04669eb9abdd3..7ba1e23c968c7ea6c318ad27b6ebe44921512f2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-05-23  Alexandre Duret-Lutz  <adl@gnu.org>
+
+       * lib/Autom4te/General.pm (END): Rewrite exit code processing.
+       Do not call `_exit()', simply modify `$?'.
+       (xsystem): Reset $! before running system, and check it afterward.
+       * tests/tools.at (autoupdating AC_PREREQ): Expect exit status
+       63 for version mismatches.
+
 2003-05-23  Akim Demaille  <akim@epita.fr>
 
        * lib/autoconf/status.m4: Prefer "TAB-SP" to "SP-TAB", because of
@@ -5,7 +13,7 @@
        the middle of a line).
        * lib/m4sugar/m4sugar.m4: Likewise.
        Remove useless spaces in comments.
-       
+
 2003-05-23  Akim Demaille  <akim@epita.fr>
 
        * lib/m4sugar/m4sugar.m4 (m4_version_prereq): Failure causes an
index 0e0070719128b80548917bdb9fecee119876b2ed..375d3cf5ba523d58f7629fe7a9d3c7a69b7b8d05 100644 (file)
@@ -1,5 +1,5 @@
 # autoconf -- create `configure' using m4 macros
-# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003  Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -89,34 +89,59 @@ sub verbose (@);
 
 # END
 # ---
-# Exit nonzero whenever closing STDOUT fails.
-# Ideally we should `exit ($? >> 8)', unfortunately, for some reason
-# I don't understand, whenever we `exit (1)' somewhere in the code,
-# we arrive here with `$? = 29'.  I suspect some low level END routine
-# might be responsible.  In this case, be sure to exit 1, not 29.
+# Filter Perl's exit codes, delete any temporary directory, and exit
+# nonzero whenever closing STDOUT fails.
 sub END
 {
-  my $exit_status = $? ? 1 : 0;
-
-  use POSIX qw (_exit);
+  # $? contains the exit status we will return.
+  # It was set using one of the following ways:
+  #
+  #  1) normal termination
+  #     this sets $? = 0
+  #  2) calling `exit (n)'
+  #     this sets $? = n
+  #  3) calling die or friends (croak, confess...):
+  #     a) when $! is non-0
+  #        this set $? = $!
+  #     b) when $! is 0 but $? is not
+  #        this sets $? = ($? >> 8)   (i.e., the exit code of the
+  #        last program executed)
+  #     c) when both $! and $? are 0
+  #        this sets $? = 255
+  #
+  # Cases 1), 2), and 3b) are fine, but we prefer $? = 1 for 3a) and 3c).
+  $? = 1 if ($! && $! == $?) || $? == 255;
+  # (Note that we cannot safely distinguish calls to `exit (n)'
+  # from calls to die when `$! = n'.  It's not big deal because
+  # we only call `exit (0)' or `exit (1)'.)
 
   if (!$debug && defined $tmp && -d $tmp)
     {
       if (<$tmp/*>)
        {
-         unlink <$tmp/*>
-           or carp ("$me: cannot empty $tmp: $!\n"), _exit (1);
+         if (! unlink <$tmp/*>)
+           {
+             print "$me: cannot empty $tmp: $!\n";
+             $? = 1;
+             return;
+           }
+       }
+      if (! rmdir $tmp)
+       {
+         print "$me: cannot remove $tmp: $!\n";
+         $? = 1;
+         return;
        }
-      rmdir $tmp
-       or carp ("$me: cannot remove $tmp: $!\n"), _exit (1);
     }
 
   # This is required if the code might send any output to stdout
   # E.g., even --version or --help.  So it's best to do it unconditionally.
-  close STDOUT
-    or (carp "$me: closing standard output: $!\n"), _exit (1);
-
-  _exit ($exit_status);
+  if (! close STDOUT)
+    {
+      print "$me: closing standard output: $!\n";
+      $? = 1;
+      return;
+    }
 }
 
 
@@ -495,10 +520,20 @@ sub xsystem ($)
 
   verbose "running: $command";
 
-  (system $command) == 0
-    or error ((split (' ', $command))[0]
-             . " failed with exit status: "
-             . WEXITSTATUS ($?));
+  $! = 0;
+
+  if (system $command)
+  {
+    $command = (split (' ', $command))[0];
+    if ($!)
+      {
+       error "failed to run $command: $!";
+      }
+    else
+      {
+       error "$command failed with exit status: " . WEXITSTATUS ($?);
+      }
+  }
 }
 
 
index 5e98ef38077bc047eb12363191c702c687978c0f..e851331c60fef0cb7bc302b7bbfde209cbf4666b 100644 (file)
@@ -599,6 +599,6 @@ AT_CHECK([echo "AC_PREREQ($autoupdate_version)" | autoupdate -],
         0, [expout], [])
 
 AT_CHECK([echo "AC_PREREQ(999.99)" | autoupdate -],
-        1, [], [ignore])
+        63, [], [ignore])
 
 AT_CLEANUP