autoconf-patches
[Top][All Lists]
Advanced

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

03-ac-eval-stderr.patch


From: Akim Demaille
Subject: 03-ac-eval-stderr.patch
Date: 16 Jan 2001 11:25:00 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Crater Lake)

I'm applying this patch so that Harlan can test it quickly, but of
course, comments, even post comments, are most welcome :)

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        Work around the Ultrix limitations on ``multiple redirections''.
        Reported by Harlan Stenn.
        
        * acgeneral.m4 (_AC_EVAL_STDERR): New.
        (_AC_PREPROC_IFELSE): Use it.
        
Index: acgeneral.m4
--- acgeneral.m4 Mon, 15 Jan 2001 23:22:32 +0100 akim (ace/27_acgeneral. 
1.169.8.111 666)
+++ acgeneral.m4 Mon, 15 Jan 2001 23:58:51 +0100 akim (ace/27_acgeneral. 
1.169.8.111 666)
@@ -2237,6 +2237,23 @@ AC_DEFUN([_AC_EVAL],
   (exit $ac_status); }])
 
 
+# _AC_EVAL_STDERR(COMMAND)
+# ------------------------
+# Eval COMMAND, save its stderr into conftest.err, save the exit status
+# in ac_status, and log it.
+# Note that when tracing, most shells will leave the traces in stderr
+
+AC_DEFUN([_AC_EVAL_STDERR],
+[{ (eval echo "$as_me:__oline__: \"$1\"") >&AS_MESSAGE_LOG_FD
+  (eval $1) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+  (exit $ac_status); }])
+
+
 # AC_TRY_EVAL(VARIABLE)
 # ---------------------
 # The purpose of this macro is to "configure:123: command line"
@@ -2725,14 +2742,13 @@ m4_define([AH_CHECK_LIB],
 # Run cpp and set ac_cpp_err to "yes" for an error, to
 # "$ac_(c,cxx)_preproc_warn_flag" if there are warnings or to "" if
 # neither warnings nor errors have been detected.  eval is necessary
-# to expand ac_cpp.  It may put trace lines to conftest.err when run
-# under sh -x (e.g. when zsh is used), so we filter them out.
+# to expand ac_cpp.
 #
 # This macro can be used during the selection of a preprocessor.
 AC_DEFUN([_AC_PREPROC_IFELSE],
 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
-if AC_TRY_COMMAND([$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.err]); then
-  if egrep -v '^ *\+' conftest.err | grep . >/dev/null; then
+if _AC_EVAL_STDERR([$ac_cpp conftest.$ac_ext >/dev/null]); then
+  if test -s conftest.err; then
     ac_cpp_err=$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag
   else
     ac_cpp_err=
@@ -2743,7 +2759,6 @@ AC_DEFUN([_AC_PREPROC_IFELSE],
 if test -z "$ac_cpp_err"; then
   m4_default([$2], :)
 else
-  cat conftest.err >&AS_MESSAGE_LOG_FD
   echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
   cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
   $3
Index: aclang.m4
--- aclang.m4 Fri, 12 Jan 2001 22:48:19 +0100 akim (ace/b/32_aclang.m4 1.5.3.67 
666)
+++ aclang.m4 Mon, 15 Jan 2001 23:33:40 +0100 akim (ace/b/32_aclang.m4 1.5.3.67 
666)
@@ -805,7 +805,7 @@ AC_DEFUN([AC_PROG_CPP],
     # Double quotes because CPP needs to be expanded
     for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
     do
-      _AC_PROG_PREPROC_WORKS()
+      _AC_PROG_PREPROC_WORKS
       if test -z "$ac_cpp_err"; then
         break
       fi
@@ -814,7 +814,7 @@ AC_DEFUN([AC_PROG_CPP],
   ])dnl
   CPP=$ac_cv_prog_CPP
 else
-  _AC_PROG_PREPROC_WORKS()
+  _AC_PROG_PREPROC_WORKS
   ac_cv_prog_CPP=$CPP
 fi
 AC_MSG_RESULT([$CPP])
@@ -1629,10 +1629,10 @@ AC_DEFUN([_AC_PROG_F77_V_OUTPUT],
 
 AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
 
-# Compile and link our simple test program by passing a flag
-# (argument 1 to this macro) to the Fortran 77 compiler in
-# order to get "verbose" output that we can then parse for the
-# Fortran 77 linker flags.
+# Compile and link our simple test program by passing a flag (argument
+# 1 to this macro) to the Fortran 77 compiler in order to get
+# "verbose" output that we can then parse for the Fortran 77 linker
+# flags.
 ac_save_FFLAGS=$FFLAGS
 FFLAGS="$FFLAGS m4_default([$1], [$ac_cv_prog_f77_v])"
 (eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD
Index: doc/autoconf.texi
--- doc/autoconf.texi Mon, 15 Jan 2001 23:22:32 +0100 akim (ace/16_autoconf.t 
1.61.2.99 666)
+++ doc/autoconf.texi Tue, 16 Jan 2001 00:33:18 +0100 akim (ace/16_autoconf.t 
1.61.2.99 666)
@@ -5190,6 +5190,36 @@ @node File Descriptors, Shell Substituti
 In each case the expected result is of course @file{/tmp/bar} containing
 @samp{foo} and @file{/tmp/baz} being empty.
 
+Most shells if not all (including Bash, Zsh, Ash) output traces on stderr
+including for sub shells.  This might result in undesired content if you
+meant to capture the standard error of the inner command:
+
address@hidden
+$ ash -x -c '(eval "echo foo >&2") 2>stderr'
+$ cat stderr
++ eval echo foo >&2
++ echo foo
+foo
+$ bash -x -c '(eval "echo foo >&2") 2>stderr'
+$ cat stderr
++ eval 'echo foo >&2'
+++ echo foo
+foo
+$ zsh -x -c '(eval "echo foo >&2") 2>stderr'
address@hidden Traces on startup files deleted here.}
+$ cat stderr
++zsh:1> eval echo foo >&2
++zsh:1> echo foo
+foo
address@hidden example
+
address@hidden
+You'll appreciate the various levels of details...
+
+One way out consists in grepping out uninteresting lines, hoping not to
+remove good ones...
+
+
 @node Shell Substitutions, Assignments, File Descriptors, Portable Shell
 @subsection Shell Substitutions
 



reply via email to

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