autoconf-patches
[Top][All Lists]
Advanced

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

Re: Autoconf. Generated configure file may use grep but does not unset t


From: Eric Blake
Subject: Re: Autoconf. Generated configure file may use grep but does not unset the GREP_OPTIONS.
Date: Tue, 26 May 2009 06:48:46 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Ralf Wildenhues on 4/10/2009 8:54 AM:
>>>> Thanks for the report.  I agree that unsetting GREP_OPTIONS as part of
>>>> AC_PROG_GREP (and friends) sounds reasonable,
> 
> We shouldn't unset anything that might be necessary for running the tool
> successfully, such as M4PATH.  Hmm, may GREP_OPTIONS=--binary-files=...
> be needed on w32 for some use cases within configure?

If that's the case, those users can write a wrapper script that always
provides the option.  I'm finally getting around to writing the patch to
blindly unset this variable.

According to Joey Mingrone on 4/30/2009 3:22 PM:
>> Your ls version is trying to output colors, even though it is in a
>> non-interactive context.  Almost like using GNU 'ls --color=always'
>> instead of the recommended 'ls --color=auto', except that you said it
>> wasn't GNU ls.  Are you sure you don't have some environment variable
>> (maybe LS_COLORS) exported, causing this behavior?
>
> Good call.  CLICOLOR_FORCE was set for some strange reason on both
> machines I tested on.  Unsetting this variable fixed the problem.
> It's strange that this hasn't caused problems in the past because I
> think it's been set for a long time.

I'm installing this patch, which addresses both reports of problematic
environment variables.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkob5S4ACgkQ84KuGfSFAYCVKQCfYEpi9kA65UfGesimGLMmzEUn
jHIAnA0a0waOBdDYrrXmFMeTl+laJ+fh
=q4CA
-----END PGP SIGNATURE-----
>From 0a13b71c4e3381d55cd6ff35b593945daa4e30a1 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 4 May 2009 11:00:30 -0600
Subject: [PATCH] Sanitize more problematic environment variables.

* doc/autoconf.texi (Environment Variable Index): Add more
entries, particularly for precious variables and known culprit
variables.  Needed to avoid overfull vbox.
(Special Shell Variables) <CLICOLOR_FORCE, GREP_OPTIONS>: Add
variables known to cause misbehavior.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Unset variables
known to cause problems.
* THANKS: Update.
Based on reports from Ilya Bobir and Joey Mingrone.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog           |   13 +++++++++++
 THANKS              |    2 +
 doc/autoconf.texi   |   57 ++++++++++++++++++++++++++++++++++++++++++++++++--
 lib/m4sugar/m4sh.m4 |    3 ++
 4 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 64058cb..f2fa676 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-05-26  Eric Blake  <address@hidden>
+
+       Sanitize more problematic environment variables.
+       * doc/autoconf.texi (Environment Variable Index): Add more
+       entries, particularly for precious variables and known culprit
+       variables.  Needed to avoid overfull vbox.
+       (Special Shell Variables) <CLICOLOR_FORCE, GREP_OPTIONS>: Add
+       variables known to cause misbehavior.
+       * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Unset variables
+       known to cause problems.
+       * THANKS: Update.
+       Based on reports from Ilya Bobir and Joey Mingrone.
+
 2009-05-19  Eric Blake  <address@hidden>

        Update uses of all-permissive license.
diff --git a/THANKS b/THANKS
index 8bf999a..3c2843b 100644
--- a/THANKS
+++ b/THANKS
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 7f04408..9908bcd 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -2098,6 +2098,7 @@ Configuration Actions
 results of @file{configure}.  The most typical task of
 @file{config.status} is to @emph{instantiate} files.

address@hidden@var{ITEMS}}
 This section describes the common behavior of the four standard
 instantiating macros: @code{AC_CONFIG_FILES}, @code{AC_CONFIG_HEADERS},
 @code{AC_CONFIG_COMMANDS} and @code{AC_CONFIG_LINKS}.  They all
@@ -2326,7 +2327,7 @@ Preset Output Variables
 the descriptions for those macros.  @xref{Output Variable Index}, for a
 complete list of output variables.  @xref{Installation Directory
 Variables}, for the list of the preset ones related to installation
-directories.  Below are listed the other preset ones.  They all are
+directories.  Below are listed the other preset ones, many of which are
 precious variables (@pxref{Setting Output Variables},
 @code{AC_ARG_VAR}).

@@ -2337,6 +2338,7 @@ Preset Output Variables
 @c actress

 @defvar CFLAGS
address@hidden CFLAGS
 @ovindex CFLAGS
 Debugging and optimization options for the C compiler.  If it is not set
 in the environment when @command{configure} runs, the default value is set
@@ -2391,6 +2393,7 @@ Preset Output Variables
 @end defvar

 @defvar CPPFLAGS
address@hidden CPPFLAGS
 @ovindex CPPFLAGS
 Preprocessor options for the C, C++, and Objective C preprocessors and
 compilers.  If
@@ -2415,6 +2418,7 @@ Preset Output Variables
 @end defvar

 @defvar CXXFLAGS
address@hidden CXXFLAGS
 @ovindex CXXFLAGS
 Debugging and optimization options for the C++ compiler.  It acts like
 @code{CFLAGS}, but for C++ instead of C.
@@ -2452,6 +2456,7 @@ Preset Output Variables
 @end defvar

 @defvar ERLCFLAGS
address@hidden ERLCFLAGS
 @ovindex ERLCFLAGS
 Debugging and optimization options for the Erlang compiler.  If it is not set
 in the environment when @command{configure} runs, the default value is empty.
@@ -2460,6 +2465,7 @@ Preset Output Variables
 @end defvar

 @defvar FCFLAGS
address@hidden FCFLAGS
 @ovindex FCFLAGS
 Debugging and optimization options for the Fortran compiler.  If it
 is not set in the environment when @command{configure} runs, the default
@@ -2469,6 +2475,7 @@ Preset Output Variables
 @end defvar

 @defvar FFLAGS
address@hidden FFLAGS
 @ovindex FFLAGS
 Debugging and optimization options for the Fortran 77 compiler.  If it
 is not set in the environment when @command{configure} runs, the default
@@ -2478,6 +2485,7 @@ Preset Output Variables
 @end defvar

 @defvar LDFLAGS
address@hidden LDFLAGS
 @ovindex LDFLAGS
 Options for the linker.  If it is not set
 in the environment when @command{configure} runs, the default value is empty.
@@ -2494,6 +2502,7 @@ Preset Output Variables
 @end defvar

 @defvar LIBS
address@hidden LIBS
 @ovindex LIBS
 @option{-l} options to pass to the linker.  The default value is empty,
 but some Autoconf macros may prepend extra libraries to this variable if
@@ -2503,6 +2512,7 @@ Preset Output Variables
 @end defvar

 @defvar OBJCFLAGS
address@hidden OBJCFLAGS
 @ovindex OBJCFLAGS
 Debugging and optimization options for the Objective C compiler.  It
 acts like @code{CFLAGS}, but for Objective C instead of C.
@@ -3996,6 +4006,8 @@ Particular Programs

 @defmac AC_PROG_YACC
 @acindex{PROG_YACC}
address@hidden YACC
address@hidden YFLAGS
 @ovindex YACC
 If @code{bison} is found, set output variable @code{YACC} to @samp{bison
 -y}.  Otherwise, if @code{byacc} is found, set @code{YACC} to
@@ -6704,6 +6716,8 @@ C Compiler

 @defmac AC_PROG_CC (@ovar{compiler-search-list})
 @acindex{PROG_CC}
address@hidden CC
address@hidden CFLAGS
 @ovindex CC
 @ovindex CFLAGS
 Determine a C compiler to use.  If @code{CC} is not already set in the
@@ -6764,6 +6778,7 @@ C Compiler

 @defmac AC_PROG_CPP
 @acindex{PROG_CPP}
address@hidden CPP
 @ovindex CPP
 Set output variable @code{CPP} to a command that runs the
 C preprocessor.  If @samp{$CC -E} doesn't work, @file{/lib/cpp} is used.
@@ -7095,6 +7110,8 @@ C++ Compiler

 @defmac AC_PROG_CXX (@ovar{compiler-search-list})
 @acindex{PROG_CXX}
address@hidden CXX
address@hidden CXXFLAGS
 @ovindex CXX
 @ovindex CXXFLAGS
 Determine a C++ compiler to use.  Check whether the environment variable
@@ -7126,6 +7143,7 @@ C++ Compiler

 @defmac AC_PROG_CXXCPP
 @acindex{PROG_CXXCPP}
address@hidden CXXCPP
 @ovindex CXXCPP
 Set output variable @code{CXXCPP} to a command that runs the C++
 preprocessor.  If @samp{$CXX -E} doesn't work, @file{/lib/cpp} is used.
@@ -7154,6 +7172,8 @@ Objective C Compiler

 @defmac AC_PROG_OBJC (@ovar{compiler-search-list})
 @acindex{PROG_OBJC}
address@hidden OBJC
address@hidden OBJCFLAGS
 @ovindex OBJC
 @ovindex OBJCFLAGS
 Determine an Objective C compiler to use.  If @code{OBJC} is not already
@@ -7180,6 +7200,7 @@ Objective C Compiler

 @defmac AC_PROG_OBJCPP
 @acindex{PROG_OBJCPP}
address@hidden OBJCPP
 @ovindex OBJCPP
 Set output variable @code{OBJCPP} to a command that runs the Objective C
 preprocessor.  If @samp{$OBJC -E} doesn't work, @file{/lib/cpp} is used.
@@ -7195,6 +7216,8 @@ Erlang Compiler and Interpreter

 @defmac AC_ERLANG_PATH_ERLC (@ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{ERLANG_PATH_ERLC}
address@hidden ERLC
address@hidden ERLCFLAGS
 @ovindex ERLC
 @ovindex ERLCFLAGS
 Determine an Erlang compiler to use.  If @code{ERLC} is not already set in the
@@ -7221,6 +7244,7 @@ Erlang Compiler and Interpreter

 @defmac AC_ERLANG_PATH_ERL (@ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{ERLANG_PATH_ERL}
address@hidden ERL
 @ovindex ERL
 Determine an Erlang interpreter to use.  If @code{ERL} is not already
 set in the
@@ -7266,6 +7290,8 @@ Fortran Compiler

 @defmac AC_PROG_F77 (@ovar{compiler-search-list})
 @acindex{PROG_F77}
address@hidden F77
address@hidden FFLAGS
 @ovindex F77
 @ovindex FFLAGS
 Determine a Fortran 77 compiler to use.  If @code{F77} is not already
@@ -7294,6 +7320,8 @@ Fortran Compiler

 @defmac AC_PROG_FC (@ovar{compiler-search-list}, @ovar{dialect})
 @acindex{PROG_FC}
address@hidden FC
address@hidden FCFLAGS
 @ovindex FC
 @ovindex FCFLAGS
 Determine a Fortran compiler to use.  If @code{FC} is not already set in
@@ -14941,6 +14969,7 @@ Special Shell Variables
 @end example

 @item _
address@hidden _
 Many shells reserve @samp{$_} for various purposes, e.g., the name of
 the last command executed.

@@ -14975,6 +15004,14 @@ Special Shell Variables
 Configure scripts use M4sh, which automatically unsets @env{CDPATH} if
 possible, so you need not worry about this problem in those scripts.

address@hidden CLICOLOR_FORCE
address@hidden CLICOLOR_FORCE
+When this variable is set, some implementations of tools like
address@hidden attempt to add color to their output via terminal escape
+sequences, even when the output is not directed to a terminal, and can
+thus cause spurious failures in scripts.  Configure scripts use M4sh,
+which automatically unsets this variable.
+
 @item DUALCASE
 @evindex DUALCASE
 In the MKS shell, case statements and file name generation are
@@ -15013,12 +15050,21 @@ Special Shell Variables
 see @pxref{unset, , Limitations of Shell Builtins}).

 @item FPATH
address@hidden FPATH
 The Korn shell uses @env{FPATH} to find shell functions, so avoid
 @env{FPATH} in portable scripts.  @env{FPATH} is consulted after
 @env{PATH}, but you still need to be wary of tests that use @env{PATH}
 to find whether a command exists, since they might report the wrong
 result if @env{FPATH} is also set.

address@hidden GREP_OPTIONS
address@hidden GREP_OPTIONS
+When this variable is set, some implementations of @command{grep} honor
+these options, even if the options include direction to enable colored
+output via terminal escape sequences, and the result can cause spurious
+failures when the output is not directed to a terminal.  Configure
+scripts use M4sh, which automatically unsets this variable.
+
 @item IFS
 @evindex IFS
 Long ago, shell scripts inherited @env{IFS} from the environment,
@@ -15090,6 +15136,7 @@ Special Shell Variables
 etc.)@: as described above.

 @item LINENO
address@hidden LINENO
 Most modern shells provide the current line number in @code{LINENO}.
 Its value is the line number of the beginning of the current command.
 M4sh, and hence Autoconf, attempts to execute @command{configure} with
@@ -15258,6 +15305,7 @@ Special Shell Variables
 @samp{$PWD}.

 @item RANDOM
address@hidden RANDOM
 Many shells provide @code{RANDOM}, a variable that returns a different
 integer each time it is used.  Most of the time, its value does not
 change when it is not used, but on @sc{irix} 6.5 the value changes all
@@ -15266,6 +15314,7 @@ Special Shell Variables
 shouldn't rely on @code{$RANDOM} expanding to a nonempty string.

 @item status
address@hidden status
 This variable is an alias to @samp{$?} for @code{zsh} (at least 3.1.6),
 hence read-only.  Do not use it.
 @end table
@@ -22057,6 +22106,8 @@ AC_ACT_IFELSE vs AC_TRY_ACT
 @c the anchor keeps the old node name, to try to avoid breaking links
 @anchor{AC_FOO_IFELSE vs AC_TRY_FOO}

address@hidden@var{ACT}_IFELSE}
address@hidden@var{ACT}}
 Since Autoconf 2.50, internal codes uses @code{AC_PREPROC_IFELSE},
 @code{AC_COMPILE_IFELSE}, @code{AC_LINK_IFELSE}, and
 @code{AC_RUN_IFELSE} on one hand and @code{AC_LANG_SOURCES},
@@ -23620,8 +23671,8 @@ Indices
 @node Environment Variable Index
 @appendixsec Environment Variable Index

-This is an alphabetical list of the environment variables that Autoconf
-checks.
+This is an alphabetical list of the environment variables that might
+influence Autoconf checks.

 @printindex ev

diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 3c05201..c7b0bff 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -274,6 +274,9 @@ shell if you do have one.], [$[]0: ], [], [62])")
 fi
 SHELL=${CONFIG_SHELL-/bin/sh}
 export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
 _m4_popdef([AS_EXIT])])# _AS_DETECT_BETTER_SHELL


-- 
1.6.3.rc3.2.g4b51


reply via email to

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