Reported by Harlan Stenn.
* acgeneral.m4 (_AC_EVAL_STDERR): New.
(_AC_PREPROC_IFELSE): Use it.
+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.
(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"
# 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=
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
# 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
])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])
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
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
# 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
])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])
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
# 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
])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])
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
(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"
# 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=
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
# 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
])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])
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
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@