]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Work around the Ultrix limitations on ``multiple redirections''.
authorAkim Demaille <akim@epita.fr>
Tue, 16 Jan 2001 20:46:00 +0000 (20:46 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 16 Jan 2001 20:46:00 +0000 (20:46 +0000)
Reported by Harlan Stenn.
* acgeneral.m4 (_AC_EVAL_STDERR): New.
(_AC_PREPROC_IFELSE): Use it.

ChangeLog
acgeneral.m4
aclang.m4
doc/autoconf.texi
lib/autoconf/c.m4
lib/autoconf/fortran.m4
lib/autoconf/general.m4
lib/autoconf/lang.m4
tests/Makefile.in

index bddfc8dcbf372d98d21bfab6a3ce5b7e1e145a23..a28cb4ab9f0d2e0b352c24bfbefc449212ff01fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-01-16  Akim Demaille  <akim@epita.fr>
+
+       Work around the Ultrix limitations on ``multiple redirections''.
+       Reported by Harlan Stenn.
+
+       * acgeneral.m4 (_AC_EVAL_STDERR): New.
+       (_AC_PREPROC_IFELSE): Use it.
+
 2001-01-16  Akim Demaille  <akim@epita.fr>
 
        * tests/atgeneral.m4 (AT_data_files): Fix the computation of PATH.
index a1fd5a66f3de04951ecdfd4504e1c6b7e7d63c23..9849c2581367b7b09c5717df891df0d8bdb739d1 100644 (file)
@@ -2240,6 +2240,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"
@@ -2721,14 +2738,13 @@ m4_popdef([AC_Lib_Name])dnl
 # 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=
@@ -2739,7 +2755,6 @@ fi
 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 ea42bc2770d536822021ba4d846a4ecef7644254..20d0ff89414891d5746653a39a58b8434b87ce94 100644 (file)
--- a/aclang.m4
+++ b/aclang.m4
@@ -805,7 +805,7 @@ if test -z "$CPP"; then
     # 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 @@ if test -z "$CPP"; then
   ])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_LANG_PUSH(Fortran 77)dnl
 
 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 aca01d27b0a1d46766eeb3371528752083c12de7..716daf85802416872f9a4e57978811b0ef0433b5 100644 (file)
@@ -5201,6 +5201,36 @@ escape, while @samp{echo `cd /zorglub 2>/dev/null`} works properly.
 It is worth noting that Zsh (but not Ash nor Bash) makes it possible
 in assignments though: @samp{foo=`cd /zorglub` 2>/dev/null}.
 
+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:
+
+@example
+$ 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'
+@i{# Traces on startup files deleted here.}
+$ cat stderr
++zsh:1> eval echo foo >&2
++zsh:1> echo foo
+foo
+@end example
+
+@noindent
+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
 
index ea42bc2770d536822021ba4d846a4ecef7644254..20d0ff89414891d5746653a39a58b8434b87ce94 100644 (file)
@@ -805,7 +805,7 @@ if test -z "$CPP"; then
     # 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 @@ if test -z "$CPP"; then
   ])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_LANG_PUSH(Fortran 77)dnl
 
 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 ea42bc2770d536822021ba4d846a4ecef7644254..20d0ff89414891d5746653a39a58b8434b87ce94 100644 (file)
@@ -805,7 +805,7 @@ if test -z "$CPP"; then
     # 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 @@ if test -z "$CPP"; then
   ])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_LANG_PUSH(Fortran 77)dnl
 
 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 a1fd5a66f3de04951ecdfd4504e1c6b7e7d63c23..9849c2581367b7b09c5717df891df0d8bdb739d1 100644 (file)
@@ -2240,6 +2240,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"
@@ -2721,14 +2738,13 @@ m4_popdef([AC_Lib_Name])dnl
 # 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=
@@ -2739,7 +2755,6 @@ fi
 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 ea42bc2770d536822021ba4d846a4ecef7644254..20d0ff89414891d5746653a39a58b8434b87ce94 100644 (file)
@@ -805,7 +805,7 @@ if test -z "$CPP"; then
     # 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 @@ if test -z "$CPP"; then
   ])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_LANG_PUSH(Fortran 77)dnl
 
 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 59b1de9d6e9a8dd03926e605e2bb63c94ea3363e..ba425aa87673a57a99b14499a057ac62a99e0020 100644 (file)
@@ -84,7 +84,7 @@ CLEANFILES = debug-*.sh macro configure configure.in configure.ac              c
 DISTCLEANFILES = atconfig testsuite
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_CLEAN_FILES =  atconfig
-DIST_COMMON =  README Makefile.am Makefile.in atconfig.in configure
+DIST_COMMON =  README Makefile.am Makefile.in atconfig.in
 
 
 PACKAGE = @PACKAGE@