autoconf-patches
[Top][All Lists]
Advanced

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

Re: 5.005_03, BeOS: incorrect $? after system invocation (Was: 2.53b on


From: Akim Demaille
Subject: Re: 5.005_03, BeOS: incorrect $? after system invocation (Was: 2.53b on BeOS, 7 failures)
Date: 29 Aug 2002 09:11:28 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

| | 505 >perl -e 'system ("false"); print STDERR "$?\n";'
| | 1
| 
| Ouch!!!  That's the culprit.

I'm applying the following patch.  Could you make sure it solves your
issue?  Thanks!

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * lib/Autom4te/General.pm (&xqx): New.
        (xsystem): Use WIFEXITED and WEXITSTATUS instead of decoding $? by
        hand, which is not portable.
        * bin/autom4te.in (&freeze, &handle_m4): Use them.

Index: bin/autom4te.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autom4te.in,v
retrieving revision 1.67
diff -u -u -r1.67 autom4te.in
--- bin/autom4te.in 30 Jul 2002 00:42:58 -0000 1.67
+++ bin/autom4te.in 29 Aug 2002 07:03:34 -0000
@@ -612,22 +612,15 @@
   #
   # We don't output directly to the cache files, to avoid problems
   # when we are interrupted (that leaves corrupted files).
-  my $command = ("$m4"
-                . join (' --include=', '', @include)
-                . " --define=m4_warnings=$m4_warnings"
-                . ' --debug=aflq'
-                . " --error-output=$tcache" . $req->id . "t"
-                . join (' --trace=',   '', sort @macro)
-                . " @ARGV"
-                . ' </dev/null'
-                . " >$ocache" . $req->id . "t");
-  verbose "running: $command";
-  system $command;
-  if ($?)
-    {
-      verbose "$m4: failed with exit status: " . ($? >> 8) . "\n";
-      exit $? >> 8;
-    }
+  xsystem ("$m4"
+          . join (' --include=', '', @include)
+          . " --define=m4_warnings=$m4_warnings"
+          . ' --debug=aflq'
+          . " --error-output=$tcache" . $req->id . "t"
+          . join (' --trace=',   '', sort @macro)
+          . " @ARGV"
+          . ' </dev/null'
+          . " >$ocache" . $req->id . "t");
 
   # Everything went ok: preserve the outputs.
   foreach my $file (map { $_ . $req->id } ($tcache, $ocache))
@@ -1062,21 +1055,14 @@
 
   # When processing the file with diversion disabled, there must be no
   # output but comments and empty lines.
-  my $command = ("$m4"
-                . ' --fatal-warning'
-                . join (' --include=', '', @include)
-                . ' --define=divert'
-                . " @ARGV"
-                . ' </dev/null');
-  verbose "running: $command";
-  my $result = `$command`;
+  my $result = xqx ("$m4"
+                   . ' --fatal-warning'
+                   . join (' --include=', '', @include)
+                   . ' --define=divert'
+                   . " @ARGV"
+                   . ' </dev/null');
   $result =~ s/#.*\n//g;
   $result =~ s/^\n//mg;
-  if ($?)
-    {
-      verbose "$m4: failed with exit status: " . ($? >> 8) . "\n";
-      exit $? >> 8;
-    }
   if ($result)
     {
       print STDERR "$me: freezing produced output:\n$result";
@@ -1085,19 +1071,12 @@
 
   # If freezing produces output, something went wrong: a bad `divert',
   # or an improper paren etc.
-  $command = ("$m4"
-             . ' --fatal-warning'
-             . join (' --include=', '', @include)
-             . " --freeze-state=$output"
-             . " @ARGV"
-             . ' </dev/null');
-  verbose "running: $command";
-  system $command;
-  if ($?)
-    {
-      verbose "$m4: failed with exit status: " . ($? >> 8) . "\n";
-      exit $? >> 8;
-    }
+  xsystem ("$m4"
+          . ' --fatal-warning'
+          . join (' --include=', '', @include)
+          . " --freeze-state=$output"
+          . " @ARGV"
+          . ' </dev/null');
 }
 
 ## -------------- ##
Index: lib/Autom4te/General.pm
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/Autom4te/General.pm,v
retrieving revision 1.21
diff -u -u -r1.21 General.pm
--- lib/Autom4te/General.pm 17 Jul 2002 16:07:33 -0000 1.21
+++ lib/Autom4te/General.pm 29 Aug 2002 07:03:35 -0000
@@ -40,7 +40,7 @@
   qw (&backname &catfile &canonpath &debug
       &file_name_is_absolute &find_configure_ac &find_file
       &getopt &mktmpdir &mtime
-      &uniq &update_file &up_to_date_p &verbose &xsystem);
+      &uniq &update_file &up_to_date_p &verbose &xsystem &xqx);
 
 # Functions we forward (coming from modules we use).
 my @export_forward_subs =
@@ -448,10 +448,35 @@
 }
 
 
+# xqx ($COMMAND)
+# --------------
+# Same as `qx' (but in scalar context), but fails on errors.
+sub xqx ($)
+{
+  use POSIX qw (WIFEXITED WEXITSTATUS);
+
+  my ($command) = @_;
+
+  verbose "running: $command";
+  my $res = `$command`;
+
+  croak ("$me: "
+        . (split (' ', $command))[0]
+        . " failed with exit status: "
+        . WEXITSTATUS ($?)
+        . "\n")
+    if WIFEXITED ($?) && WEXITSTATUS ($?) != 0;
+
+  return $res;
+}
+
+
 # xsystem ($COMMAND)
 # ------------------
 sub xsystem ($)
 {
+  use POSIX qw (WEXITSTATUS);
+
   my ($command) = @_;
 
   verbose "running: $command";
@@ -460,7 +485,7 @@
     or croak ("$me: "
              . (split (' ', $command))[0]
              . " failed with exit status: "
-             . ($? >> 8)
+             . WEXITSTATUS ($?)
              . "\n");
 }
 




reply via email to

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