autoconf-commit
[Top][All Lists]
Advanced

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

[SCM] GNU Autoconf source repository branch, master, updated. v2.63-49-g


From: Paolo Bonzini
Subject: [SCM] GNU Autoconf source repository branch, master, updated. v2.63-49-g2079086
Date: Wed, 15 Oct 2008 14:07:23 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Autoconf source repository".

http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=2079086ce2fa69ee0bce8e0a9cf65f57019877b1

The branch, master has been updated
       via  2079086ce2fa69ee0bce8e0a9cf65f57019877b1 (commit)
       via  26ba5ebd23bcee95d446181b57dac61d7163c041 (commit)
       via  d73b293fd3508e995905a538c1725c19b2d6d846 (commit)
       via  cde022163b2e104f23c7ea70288fc9136fe2b765 (commit)
      from  6265de13feb09b7bb67a8fbe406dd71a2554f61c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2079086ce2fa69ee0bce8e0a9cf65f57019877b1
Author: Paolo Bonzini <address@hidden>
Date:   Wed Oct 15 11:03:35 2008 +0200

    Updates to shell portability documentation
    
    * doc/autoconf.texi: Updates all references to "Portable Shell" and
    "Limitations of Builtins" to use three-argument commands.
    (Programming in M4sh): Document AS_ECHO, AS_ECHO_N, AS_UNSET.
    (Portable Shell): Move here discussion about "Where is the POSIX
    shell?"  Mention that M4sh provides a SVR2 shell and takes care
    of unsetting variables if necessary.  Talk about M4sh and not only
    Autoconf-generated scripts.
    (Special Shell Variables): Talk about M4sh and not only
    Autoconf-generated scripts.  Don't talk about things that Autoconf
    does not do.  Mention problems of $LINENO with shell functions.
    (Limitations of Builtins).  Mention AS_ECHO and AS_ECHO_N.  Move
    discussion of eval bugs before discussion on proper use of eval.
    Mention AS_IF.  Reword why not to use "shift N".  Mention "foo=;
    unset foo" trick.  Include M4sh code that unsets MAIL for Bash 2.01.
    * NEWS: Update list of documented M4sh macros.

commit 26ba5ebd23bcee95d446181b57dac61d7163c041
Author: Paolo Bonzini <address@hidden>
Date:   Tue Oct 14 07:16:48 2008 +0200

    Assume a (possibly buggy) `unset' is present after a `better shell' was 
found.
    
    * lib/autoconf/general.m4 (_AC_CACHE_DUMP): Use AS_UNSET.
    * lib/autoconf/programs.m4 (AC_PROG_SED): Use AS_UNSET.
    * lib/m4sugar/m4sh.m4 (_AS_UNSET_PREPARE): Provide $as_unset as an
    alias for AS_UNSET, for backwards compatibility.
    (_AS_DETECT_BETTER_SHELL): Set BASH_ENV and ENV to /dev/null in case
    the shell does not support unset.
    (_AS_SHELL_SANITIZE): Work around Bash 2.01 bugs.  Unset BASH_ENV.
    (AS_INIT, _AS_PREPARE, AS_PREPARE): Call it.
    (AS_UNSET): Assume it is there but it might fail if the variable is
    not set.  Use it throughout instead of $as_unset.

commit d73b293fd3508e995905a538c1725c19b2d6d846
Author: Paolo Bonzini <address@hidden>
Date:   Wed Oct 15 11:02:09 2008 +0200

    Turn AS_SHELL_SANITIZE into a for-Libtool-only wrapper.
    
    * lib/m4sugar/m4sh.m4 (_AS_DETECT_REQUIRED, _AS_DETECT_SUGGESTED): Remove
    m4_require of _AS_DETECT_BETTER_SHELL.
    (_AS_CLEANUP): Add it here.
    (_AS_DETECT_BETTER_SHELL): Just expand the test instead of appending it
    to _AS_CLEANUP.
    (_AS_SHELL_SANITIZE): New name of the old AS_SHELL_SANITIZE macro.
    (AS_SHELL_SANITIZE): New macro hacking around Libtool misuse.
    (AS_PREPARE): Use _AS_SHELL_SANITIZE.
    (AS_INIT): Add m4_provide of itself.

commit cde022163b2e104f23c7ea70288fc9136fe2b765
Author: Paolo Bonzini <address@hidden>
Date:   Wed Oct 15 15:59:42 2008 +0200

    Use "test x$foo = xyes" to avoid upsetting Libtool's sh.test.
    
    * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL, _AS_SHELL_FN_WORK): Use
    "test x$foo = xyes".

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                |   53 +++++++++
 NEWS                     |    3 +
 doc/autoconf.texi        |  276 ++++++++++++++++++++++++++++------------------
 lib/autoconf/general.m4  |    2 +-
 lib/autoconf/programs.m4 |    2 +-
 lib/m4sugar/m4sh.m4      |  112 +++++++++++--------
 6 files changed, 293 insertions(+), 155 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7cbb670..9789f57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,58 @@
 2008-10-15  Paolo Bonzini  <address@hidden>
 
+       Updates to shell portability documentation.
+       * doc/autoconf.texi: Updates all references to "Portable Shell" and
+       "Limitations of Builtins" to use three-argument commands.
+       (Programming in M4sh): Document AS_ECHO, AS_ECHO_N, AS_UNSET.
+       (Portable Shell): Move here discussion about "Where is the POSIX
+       shell?"  Mention that M4sh provides a SVR2 shell and takes care
+       of unsetting variables if necessary.  Talk about M4sh and not only
+       Autoconf-generated scripts.
+       (Special Shell Variables): Talk about M4sh and not only
+       Autoconf-generated scripts.  Don't talk about things that Autoconf
+       does not do.  Mention problems of $LINENO with shell functions.
+       (Limitations of Builtins).  Mention AS_ECHO and AS_ECHO_N.  Move
+       discussion of eval bugs before discussion on proper use of eval.
+       Mention AS_IF.  Reword why not to use "shift N".  Mention "foo=;
+       unset foo" trick.  Include M4sh code that unsets MAIL for Bash 2.01.
+       * NEWS: Update list of documented M4sh macros.
+
+2008-10-15  Paolo Bonzini  <address@hidden>
+
+       Assume a (possibly buggy) `unset' is present after a
+       `better shell' was found.
+       * lib/autoconf/general.m4 (_AC_CACHE_DUMP): Use AS_UNSET.
+       * lib/autoconf/programs.m4 (AC_PROG_SED): Use AS_UNSET.
+       * lib/m4sugar/m4sh.m4 (_AS_UNSET_PREPARE): Provide $as_unset as an
+       alias for AS_UNSET, for backwards compatibility.
+       (_AS_DETECT_BETTER_SHELL): Set BASH_ENV and ENV to /dev/null in case
+       the shell does not support unset.
+       (_AS_SHELL_SANITIZE): Work around Bash 2.01 bugs.  Unset BASH_ENV.
+       (AS_INIT, _AS_PREPARE, AS_PREPARE): Call it.
+       (AS_UNSET): Assume it is there but it might fail if the variable is
+       not set.  Use it throughout instead of $as_unset.
+
+2008-10-15  Paolo Bonzini  <address@hidden>
+
+       Turn AS_SHELL_SANITIZE into a for-Libtool-only wrapper.
+       * lib/m4sugar/m4sh.m4 (_AS_DETECT_REQUIRED, _AS_DETECT_SUGGESTED): 
Remove
+       m4_require of _AS_DETECT_BETTER_SHELL.
+       (_AS_CLEANUP): Add it here.
+       (_AS_DETECT_BETTER_SHELL): Just expand the test instead of appending it
+       to _AS_CLEANUP.
+       (_AS_SHELL_SANITIZE): New name of the old AS_SHELL_SANITIZE macro.
+       (AS_SHELL_SANITIZE): New macro hacking around Libtool misuse.
+       (AS_PREPARE): Use _AS_SHELL_SANITIZE.
+       (AS_INIT): Add m4_provide of itself.
+
+2008-10-15  Paolo Bonzini  <address@hidden>
+
+       Use "test x$foo = xyes" to avoid upsetting Libtool's sh.test.
+       * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL, _AS_SHELL_FN_WORK): Use
+       "test x$foo = xyes".
+
+2008-10-15  Paolo Bonzini  <address@hidden>
+
        Trim down the size of the better-shell test.
        * lib/m4sugar/m4sh.at (_AT_DETECT_BETTER_SHELL): Store the common
        snippets into shell variables.
diff --git a/NEWS b/NEWS
index 31e58c6..2f7914a 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,9 @@ GNU Autoconf NEWS - User visible changes.
    AS_ME_PREPARE
 
 ** The following m4sh macros are documented now:
+   AS_ECHO
+   AS_ECHO_N
+   AS_UNSET
    AS_VERSION_COMPARE
 
 
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index ddd0638..fe51667 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -1030,9 +1030,10 @@ use.  Autoconf macros already exist to check for many 
features; see
 you can use Autoconf template macros to produce custom checks; see
 @ref{Writing Tests}, for information about them.  For especially tricky
 or specialized features, @file{configure.ac} might need to contain some
-hand-crafted shell commands; see @ref{Portable Shell}.  The
address@hidden program can give you a good start in writing
address@hidden (@pxref{autoscan Invocation}, for more information).
+hand-crafted shell commands; see @ref{Portable Shell, , Portable Shell
+Programming}.  The @command{autoscan} program can give you a good start
+in writing @file{configure.ac} (@pxref{autoscan Invocation}, for more
+information).
 
 Previous versions of Autoconf promoted the name @file{configure.in},
 which is somewhat ambiguous (the tool needed to process this file is not
@@ -11846,6 +11847,23 @@ if @code{$file} is @samp{/one/two/three}, the command
 @end defmac
 @end ignore
 
address@hidden AS_ECHO (@var{word})
address@hidden
+Emits @var{word} to the standard output, followed by a newline.  @var{word}
+must be a single shell word (typically a quoted string).  The bytes of
address@hidden are output as-is, even if it starts with "-" or contains "\".
+Redirections can be placed outside the macro invocation.
address@hidden defmac
+
address@hidden AS_ECHO_N (@var{word})
address@hidden
+Emits @var{word} to the standard output, without a following newline.
address@hidden must be a single shell word (typically a quoted string) and,
+for portability, should not include more than one newline.  The bytes of
address@hidden are output as-is, even if it starts with "-" or contains "\".
+Redirections can be placed outside the macro invocation.
address@hidden defmac
+
 @defmac AS_IF (@var{test1}, @ovar{run-if-true1}, @dots{}, @ovar{run-if-false})
 @asindex{IF}
 Run shell code @var{test1}.  If @var{test1} exits with a zero status then
@@ -11911,6 +11929,12 @@ optimizing the common cases (@var{dir} or @var{file} 
is @samp{.},
 @var{file} is absolute, etc.).
 @end defmac
 
address@hidden AS_UNSET (@var{var})
address@hidden
+Unsets the shell variable @var{var}, working around bugs in older
+shells (@pxref{Limitations of Builtins, , Limitations of Shell Builtins}).
address@hidden defmac
+
 @defmac AS_VERSION_COMPARE (@var{version-1}, @var{version-2}, @
   @ovar{action-if-less}, @ovar{action-if-equal}, @ovar{action-if-greater})
 @asindex{VERSION_COMPARE}
@@ -12731,18 +12755,52 @@ test "$ac_cv_emxos2" = yes && EMXOS2=yes[]dnl
 When writing your own checks, there are some shell-script programming
 techniques you should avoid in order to make your code portable.  The
 Bourne shell and upward-compatible shells like the Korn shell and Bash
-have evolved over the years, but to prevent trouble, do not take
-advantage of features that were added after Unix version 7, circa
-1977 (@pxref{Systemology}).
+have evolved over the years, and many features added to the original
+System7 shell are now supported on all interesting porting targets.
+However, the following discussion between Russ Allbery and Robert Lipe
+is worth reading:
 
-You should not use aliases, negated character classes, or other features
-that are not found in all Bourne-compatible shells; restrict yourself
-to the lowest common denominator.  Even @code{unset} is not supported
-by all shells!
address@hidden
+Russ Allbery:
 
-Shell functions are considered portable nowadays.  However, some pitfalls
-have to be avoided for portable use of shell functions (@pxref{Shell
-Functions}).
address@hidden
+The @acronym{GNU} assumption that @command{/bin/sh} is the one and only shell
+leads to a permanent deadlock.  Vendors don't want to break users'
+existing shell scripts, and there are some corner cases in the Bourne
+shell that are not completely compatible with a Posix shell.  Thus,
+vendors who have taken this route will @emph{never} (address@hidden say
+never'') replace the Bourne shell (as @command{/bin/sh}) with a
+Posix shell.
address@hidden quotation
+
address@hidden
+Robert Lipe:
+
address@hidden
+This is exactly the problem.  While most (at least most System V's) do
+have a Bourne shell that accepts shell functions most vendor
address@hidden/bin/sh} programs are not the Posix shell.
+
+So while most modern systems do have a shell @emph{somewhere} that meets the
+Posix standard, the challenge is to find it.
address@hidden quotation
+
+For this reason, part of the job of M4sh (@pxref{Programming in M4sh})
+is to find such a shell.  But to prevent trouble, if you're not using
+M4sh you should not take advantage of features that were added after Unix
+version 7, circa 1977 (@pxref{Systemology}); you should not use aliases,
+negated character classes, or even @command{unset}.  @code{#} comments,
+while not in Unix version 7, were retrofitted in the original Bourne
+shell and can be assumed to be part of the least common denominator.
+
+On the other hand, if you're using M4sh you can assume that the shell
+has the features that were added in SVR2, including shell functions,
address@hidden, @command{unset}, and I/O redirection for builtins.  For
+more information, refer to @uref{http://@/www.in-ulm.de/@/~mascheck/@/bourne/}.
+However, some pitfalls have to be avoided for portable use of this
+constructs; these will be documented in the rest of this chapter.
+See in particular @ref{Shell Functions} and @ref{Limitations of
+Builtins, , Limitations of Shell Builtins}.
 
 Some ancient systems have quite
 small limits on the length of the @samp{#!} line; for instance, 32
@@ -12920,34 +12978,6 @@ The default Mac OS X @command{sh} was originally Zsh; 
it was changed to
 Bash in Mac OS X 10.2.
 @end table
 
-The following discussion between Russ Allbery and Robert Lipe is worth
-reading:
-
address@hidden
-Russ Allbery:
-
address@hidden
-The @acronym{GNU} assumption that @command{/bin/sh} is the one and only shell
-leads to a permanent deadlock.  Vendors don't want to break users'
-existing shell scripts, and there are some corner cases in the Bourne
-shell that are not completely compatible with a Posix shell.  Thus,
-vendors who have taken this route will @emph{never} (address@hidden say
-never'') replace the Bourne shell (as @command{/bin/sh}) with a
-Posix shell.
address@hidden quotation
-
address@hidden
-Robert Lipe:
-
address@hidden
-This is exactly the problem.  While most (at least most System V's) do
-have a Bourne shell that accepts shell functions most vendor
address@hidden/bin/sh} programs are not the Posix shell.
-
-So while most modern systems do have a shell @emph{somewhere} that meets the
-Posix standard, the challenge is to find it.
address@hidden quotation
-
 @node Here-Documents
 @section Here-Documents
 @cindex Here-documents
@@ -13249,7 +13279,8 @@ esac
 
 @noindent
 Make sure you quote the brackets if appropriate and keep the backslash as
-first character (@pxref{Limitations of Builtins}).
+first character (@pxref{Limitations of Builtins, , Limitations of Shell
+Builtins}).
 
 Also, because the colon is used as part of a drivespec, these systems don't
 use it as path separator.  When creating or accessing paths, you can use the
@@ -13891,9 +13922,10 @@ it's not worth worrying about working around these 
horrendous bugs.
 
 Some shell variables should not be used, since they can have a deep
 influence on the behavior of the shell.  In order to recover a sane
-behavior from the shell, some variables should be unset, but
address@hidden is not portable (@pxref{Limitations of Builtins}) and a
-fallback value is needed.
+behavior from the shell, some variables should be unset; M4sh takes
+care of this and provides fallback values, whenever needed, to cater
+for a very old @file{/bin/sh} that does not support @command{unset}.
+(@pxref{Portable Shell, , Portable Shell Programming}).
 
 As a general rule, shell variable names containing a lower-case letter
 are safe; you can define and use these variables without worrying about
@@ -13940,7 +13972,7 @@ In practice the shells that have this problem also 
support
 You can also avoid output by ensuring that your directory name is
 absolute or anchored at @samp{./}, as in @samp{abs=`cd ./src && pwd`}.
 
-Autoconf-generated scripts automatically unset @env{CDPATH} if
+Configure scripts use M4sh, which automatically unsets @env{CDPATH} if
 possible, so you need not worry about this problem in those scripts.
 
 @item DUALCASE
@@ -13966,7 +13998,8 @@ supposed to affect only interactive shells.  However, 
at least one
 shell (the pre-3.0 @sc{uwin} Korn shell) gets confused about
 whether it is interactive, which means that (for example) a @env{PS1}
 with a side effect can unexpectedly modify @samp{$?}.  To work around
-this bug, Autoconf-generated scripts do something like this:
+this bug, M4sh scripts (including @file{configure} scripts) do something
+like this:
 
 @example
 (unset ENV) >/dev/null 2>&1 && unset ENV MAIL MAILPATH
@@ -13975,6 +14008,10 @@ PS2='> '
 PS4='+ '
 @end example
 
address@hidden
+(actually, there is some complication due to bugs in @command{unset};
+see @pxref{Limitations of Builtins, , Limitations of Shell Builtins}).
+
 @item FPATH
 The Korn shell uses @env{FPATH} to find shell functions, so avoid
 @env{FPATH} in portable scripts.  @env{FPATH} is consulted after
@@ -14017,20 +14054,23 @@ to this and join with a space anyway.
 @evindex LC_NUMERIC
 @evindex LC_TIME
 
-Autoconf-generated scripts normally set all these variables to
address@hidden because so much configuration code assumes the C locale and
-Posix requires that locale environment variables be set to
address@hidden if the C locale is desired.  However, some older, nonstandard
-systems (notably @acronym{SCO}) break if locale environment variables
-are set to @samp{C}, so when running on these systems
-Autoconf-generated scripts unset the variables instead.
+You should set all these variables to @samp{C} because so much
+configuration code assumes the C locale and Posix requires that locale
+environment variables be set to @samp{C} if the C locale is desired;
address@hidden scripts and M4sh do that for you.
+Export these variables after setting them.
+
address@hidden  However, some older, nonstandard
address@hidden  systems (notably @acronym{SCO}) break if locale environment 
variables
address@hidden  are set to @samp{C}, so when running on these systems
address@hidden  Autoconf-generated scripts unset the variables instead.
 
 @item LANGUAGE
 @evindex LANGUAGE
 
 @env{LANGUAGE} is not specified by Posix, but it is a @acronym{GNU}
-extension that overrides @env{LC_ALL} in some cases, so
-Autoconf-generated scripts set it too.
+extension that overrides @env{LC_ALL} in some cases, so you (or M4sh)
+should set it too.
 
 @item LC_ADDRESS
 @itemx LC_IDENTIFICATION
@@ -14060,13 +14100,13 @@ character) with the line's number.  In M4sh scripts 
you should execute
 @code{AS_LINENO_PREPARE} so that these workarounds are included in
 your script; configure scripts do this automatically in @code{AC_INIT}.
 
-You should not rely on @code{LINENO} within @command{eval}, as the
-behavior differs in practice.  Also, the possibility of the Sed
-prepass means that you should not rely on @code{$LINENO} when quoted,
-when in here-documents, or when in long commands that cross line
-boundaries.  Subshells should be OK, though.  In the following
-example, lines 1, 6, and 9 are portable, but the other instances of
address@hidden are not:
+You should not rely on @code{LINENO} within @command{eval} or shell
+functions, as the behavior differs in practice.  Also, the possibility
+of the Sed prepass means that you should not rely on @code{$LINENO} when
+quoted, when in here-documents, or when in long commands that cross line
+boundaries.  Subshells should be OK, though.  In the following example,
+lines 1, 6, and 9 are portable, but the other instances of @code{LINENO}
+are not:
 
 @example
 @group
@@ -14187,7 +14227,7 @@ hence read-only.  Do not use it.
 @cindex Shell Functions
 
 Nowadays, it is difficult to find a shell that does not support
-shell functions at all.  However, some differences should be expected:
+shell functions at all.  However, some differences should be expected.
 
 Inside a shell function, you should not rely on the error status of a
 subshell if the last command of that subshell was @code{exit} or
@@ -14260,10 +14300,11 @@ No, no, we are serious: some shells do have 
limitations!  :)
 
 You should always keep in mind that any builtin or command may support
 options, and therefore differ in behavior with arguments
-starting with a dash.  For instance, the innocent @samp{echo "$word"}
+starting with a dash.  For instance, even the innocent @samp{echo "$word"}
 can give unexpected results when @code{word} starts with a dash.  It is
 often possible to avoid this problem using @samp{echo "x$word"}, taking
-the @samp{x} into account later in the pipe.
+the @samp{x} into account later in the pipe.  Many of these limitations
+can be worked around using M4sh (@pxref{Programming in M4sh}).
 
 @table @asis
 @item @command{.}
@@ -14491,12 +14532,8 @@ Also please see the discussion of the @command{pwd} 
command.
 @prindex @command{echo}
 The simple @command{echo} is probably the most surprising source of
 portability troubles.  It is not possible to use @samp{echo} portably
-unless both options and escape sequences are omitted.  New applications
-which are not aiming at portability should use @samp{printf} instead of
address@hidden
-
-Don't expect any option.  @xref{Preset Output Variables}, @code{ECHO_N}
-etc.@: for a means to simulate @option{-n}.
+unless both options and escape sequences are omitted.  Don't expect any
+option.
 
 Do not use backslashes in the arguments, as there is no consensus on
 their handling.  For @samp{echo '\n' | wc -l}, the @command{sh} of
@@ -14517,6 +14554,12 @@ $foo
 EOF
 @end example
 
+New applications which are not aiming at portability should use
address@hidden instead of @samp{echo}.  M4sh provides the @code{AS_ECHO}
+and @code{AS_ECHO_N} macros (corresponding to @samp{echo -n} which use
address@hidden if it is available, or otherwise resort to various creative
+tricks in order to work around the above problems.
+
 
 @item @command{eval}
 @c -----------------
@@ -14524,9 +14567,27 @@ EOF
 The @command{eval} command is useful in limited circumstances, e.g.,
 using commands like @samp{eval table_$key=\$value} and @samp{eval
 value=table_$key} to simulate a hash table when the key is known to be
-alphanumeric.  However, @command{eval} is tricky to use on arbitrary
-arguments, even when it is implemented correctly.
+alphanumeric.
+
+You should also be wary of common bugs in @command{eval} implementations.
+In some shell implementations (e.g., older @command{ash}, address@hidden 3.8
address@hidden, @command{pdksh} v5.2.14 99/07/13.2, and @command{zsh}
+4.2.5), the arguments of @samp{eval} are evaluated in a context where
address@hidden is 0, so they exhibit behavior like this:
+
address@hidden
+$ @kbd{false; eval 'echo $?'}
+0
address@hidden example
+
+The correct behavior here is to output a nonzero value,
+but portable scripts should not rely on this.
+
+You should not rely on @code{LINENO} within @command{eval}.
address@hidden Shell Variables}.
 
+Note that, even though these bugs are easily avoided,
address@hidden is tricky to use on arbitrary arguments.
 It is obviously unwise to use @samp{eval $cmd} if the string value of
 @samp{cmd} was derived from an untrustworthy source.  But even if the
 string value is valid, @samp{eval $cmd} might not work as intended,
@@ -14550,23 +14611,6 @@ since it mistakenly replaces the contents of 
@file{bar} by the
 string @samp{cat foo}.  No simple, general, and portable solution to
 this problem is known.
 
-You should also be wary of common bugs in @command{eval} implementations.
-In some shell implementations (e.g., older @command{ash}, address@hidden 3.8
address@hidden, @command{pdksh} v5.2.14 99/07/13.2, and @command{zsh}
-4.2.5), the arguments of @samp{eval} are evaluated in a context where
address@hidden is 0, so they exhibit behavior like this:
-
address@hidden
-$ @kbd{false; eval 'echo $?'}
-0
address@hidden example
-
-The correct behavior here is to output a nonzero value,
-but portable scripts should not rely on this.
-
-You should not rely on @code{LINENO} within @command{eval}.
address@hidden Shell Variables}.
-
 @item @command{exec}
 @c -----------------
 @prindex @command{exec}
@@ -14752,6 +14796,18 @@ if cmp -s file file.new; then :; else
 fi
 @end example
 
address@hidden
+Or, especially if the @dfn{else} branch is short, you can use @code{||}.
+In M4sh, the @code{AS_IF} macro provides an easy way to write these kinds
+of conditionals as;
+
address@hidden
+AS_IF([cmp -s file file.new], [], [mv file.new file])
address@hidden example
+
+This is especially useful in other M4 macros, where the @dfn{then} and
address@hidden branches might be macro arguments.
+
 There are shells that do not reset the exit status from an @command{if}:
 
 @example
@@ -14917,8 +14973,8 @@ Not only is @command{shift}ing a bad idea when there is 
nothing left to
 shift, but in addition it is not portable: the shell of @acronym{MIPS
 RISC/OS} 4.52 refuses to do it.
 
-Don't use @samp{shift 2} etc.; it was not in the 7th Edition Bourne shell,
-and it is also absent in many pre-Posix shells.
+Don't use @samp{shift 2} etc.; while it in the SVR1 shell (1983),
+it is also absent in many pre-Posix shells.
 
 
 @item @command{source}
@@ -15115,23 +15171,29 @@ for @command{true}.
 @c ------------------
 @prindex @command{unset}
 In some nonconforming shells (e.g., Bash 2.05a), @code{unset FOO} fails
-when @code{FOO} is not set.  Also, Bash 2.01 mishandles @code{unset
-MAIL} in some cases and dumps core.
+when @code{FOO} is not set.  You can use
+
address@hidden
+FOO=; unset FOO
address@hidden smallexample
+
+if you are not sure that @code{FOO} is set.
 
-A few ancient shells lack @command{unset} entirely.  Nevertheless, because
-it is extremely useful to disable embarrassing variables such as
address@hidden, you can test for its existence and use
-it @emph{provided} you give a neutralizing value when @command{unset} is
-not supported:
+A few ancient shells lack @command{unset} entirely.  For some variables
+such as @code{PS1}, you can use a neutralizing value instead:
 
 @smallexample
-# "|| exit" suppresses any "Segmentation fault" message.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-  unset=unset
-else
-  unset=false
-fi
-$unset PS1 || PS1='$ '
+PS1='$ '
address@hidden smallexample
+
+Usually, shells that do not support @command{unset} need less effort to
+make the environment sane, so for example is not a problem if you cannot
+unset @command{CDPATH} on those shells.  However, Bash 2.01 mishandles
address@hidden MAIL} in some cases and dumps core.  So, you should do
+something like
+
address@hidden
+( (unset MAIL) || exit 1) >/dev/null 2>&1 && unset MAIL || :
 @end smallexample
 
 @noindent
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 986b7af..beb3104 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1894,7 +1894,7 @@ m4_define([_AC_CACHE_DUMP],
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
       BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) $as_unset $ac_var ;;
+      *) AS_UNSET([$ac_var]) ;;
       esac ;;
     esac
   done
diff --git a/lib/autoconf/programs.m4 b/lib/autoconf/programs.m4
index 63f8a13..45a74b5 100644
--- a/lib/autoconf/programs.m4
+++ b/lib/autoconf/programs.m4
@@ -894,7 +894,7 @@ AC_DEFUN([AC_PROG_SED],
        ac_script="$ac_script$as_nl$ac_script"
      done
      echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
-     $as_unset ac_script || ac_script=
+     AS_UNSET([ac_script])
      _AC_PATH_PROGS_FEATURE_CHECK(SED, [sed gsed],
        [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
                ["$ac_path_SED" -f conftest.sed])])])
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 20b5772..64cc8db 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -138,7 +138,8 @@ m4_define([_AS_BOURNE_COMPATIBLE],
 # -----------
 # Expanded as the last thing before m4sugar cleanup begins.  Macros
 # may append m4sh cleanup hooks to this as appropriate.
-m4_define([_AS_CLEANUP])
+m4_define([_AS_CLEANUP],
+[m4_divert_text([M4SH-SANITIZE], [_AS_DETECT_BETTER_SHELL])])
 
 
 # AS_COPYRIGHT(TEXT)
@@ -155,9 +156,9 @@ $1], [^], address@hidden:@ ])])])
 # _AS_DETECT_REQUIRED(TEST)
 # -------------------------
 # Refuse to execute under a shell that does not pass the given TEST.
+# Does not do AS_REQUIRE for the better-shell detection code.
 m4_defun([_AS_DETECT_REQUIRED],
-[m4_require([_AS_DETECT_BETTER_SHELL])dnl
-m4_set_add([_AS_DETECT_REQUIRED_BODY],
+[m4_set_add([_AS_DETECT_REQUIRED_BODY],
           [($1) || AS_EXIT(1)
 ])])
 
@@ -165,9 +166,9 @@ m4_set_add([_AS_DETECT_REQUIRED_BODY],
 # _AS_DETECT_SUGGESTED(TEST)
 # --------------------------
 # Prefer to execute under a shell that passes the given TEST.
+# Does not do AS_REQUIRE for the better-shell detection code.
 m4_defun([_AS_DETECT_SUGGESTED],
-[m4_require([_AS_DETECT_BETTER_SHELL])dnl
-m4_set_add([_AS_DETECT_SUGGESTED_BODY],
+[m4_set_add([_AS_DETECT_SUGGESTED_BODY],
           [($1) || AS_EXIT(1)
 ])])
 
@@ -186,10 +187,8 @@ m4_set_add([_AS_DETECT_SUGGESTED_BODY],
 # FIXME: The code should test for the OSF bug described in
 # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
 #
-m4_defun_once([_AS_DETECT_BETTER_SHELL],
-[AS_REQUIRE([_AS_UNSET_PREPARE], , [M4SH-SANITIZE])dnl
-m4_append([_AS_CLEANUP], [m4_divert_text([M4SH-SANITIZE], [
-if test "x$CONFIG_SHELL" = x; then
+m4_defun([_AS_DETECT_BETTER_SHELL],
+[if test "x$CONFIG_SHELL" = x; then
 dnl Remove any tests from suggested that are also required
   m4_set_foreach([_AS_DETECT_SUGGESTED_BODY], [AS_snippet],
                 [m4_set_contains([_AS_DETECT_REQUIRED_BODY],
@@ -203,7 +202,7 @@ dnl Remove any tests from suggested that are also required
     AS_IF([_AS_RUN(["$as_required"])],
          [as_have_required=yes],
          [as_have_required=no])])
-  AS_IF([test $as_have_required = yes && _AS_RUN(["$as_suggested"])],
+  AS_IF([test x$as_have_required = xyes && _AS_RUN(["$as_suggested"])],
     [],
     [as_candidate_shells=
     _AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
@@ -225,13 +224,16 @@ dnl Remove any tests from suggested that are also required
       done
 
       AS_IF([test "x$CONFIG_SHELL" != x],
-       [for as_var in BASH_ENV ENV
-       do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
-       done
+       [# We cannot yet assume a decent shell, so we have to provide a
+       # neutralization value for shells without unset; and this also
+       # works around shells that cannot unset nonexistent variables.
+       BASH_ENV=/dev/null
+       ENV=/dev/null
+       (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
        export CONFIG_SHELL
        exec "$CONFIG_SHELL" "$as_myself" ${1+"address@hidden"}])
 
-    AS_IF([test $as_have_required = no],
+    AS_IF([test x$as_have_required = xno],
       [echo This script requires a shell more modern than all the
       echo shells that I found on your system.  Please install a
       echo modern shell, or manually run the script under such a
@@ -239,7 +241,7 @@ dnl Remove any tests from suggested that are also required
       AS_EXIT(1)])
     ])
 fi
-])])])# _AS_DETECT_BETTER_SHELL
+])# _AS_DETECT_BETTER_SHELL
 
 
 # _AS_PREPARE
@@ -271,6 +273,7 @@ _AS_MKDIR_P_PREPARE
 _AS_TEST_PREPARE
 _AS_TR_CPP_PREPARE
 _AS_TR_SH_PREPARE
+_AS_UNSET_PREPARE
 ])
 
 # AS_PREPARE
@@ -291,6 +294,7 @@ AS_REQUIRE([_AS_MKDIR_P_PREPARE])
 AS_REQUIRE([_AS_TEST_PREPARE])
 AS_REQUIRE([_AS_TR_CPP_PREPARE])
 AS_REQUIRE([_AS_TR_SH_PREPARE])
+AS_REQUIRE([_AS_UNSET_PREPARE])
 ])
 
 
@@ -316,8 +320,7 @@ m4_if(m4_eval(_m4_divert(_m4_divert_dump) <= 
_m4_divert(_m4_divert_desired)), 1,
 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.
 #
 m4_define([AS_REQUIRE_SHELL_FN],
-[_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
-AS_REQUIRE([AS_SHELL_FN_$1], [m4_provide([AS_SHELL_FN_$1])$1 ()
+[AS_REQUIRE([AS_SHELL_FN_$1], [m4_provide([AS_SHELL_FN_$1])$1 ()
 {
 $2
 }], m4_default_quoted([$3], [M4SH-INIT-FN]))])
@@ -374,13 +377,14 @@ AS_IF([as_func_ret_failure],
 AS_IF([( set x; as_func_ret_success y && test x = "[$]1" )], [],
   [exitcode=1
   echo positional parameters were not saved.])
-test $exitcode = 0[]dnl
+test x$exitcode = x0[]dnl
 ])# _AS_SHELL_FN_WORK
 
 
-# AS_SHELL_SANITIZE
-# -----------------
-m4_defun([AS_SHELL_SANITIZE],
+# _AS_SHELL_SANITIZE
+# ------------------
+# This is the prolog that is emitted by AS_INIT and AS_INIT_GENERATED.
+m4_defun([_AS_SHELL_SANITIZE],
 [## --------------------- ##
 ## M4sh Initialization.  ##
 ## --------------------- ##
@@ -391,7 +395,6 @@ AS_BOURNE_COMPATIBLE
 _AS_CR_PREPARE
 _AS_ECHO_PREPARE
 _AS_PATH_SEPARATOR_PREPARE
-_AS_UNSET_PREPARE
 
 # IFS
 # We need space, tab and new line, in precisely that order.  Quoting is
@@ -417,9 +420,12 @@ if test ! -f "$as_myself"; then
   AS_EXIT
 fi
 
-# Work around bugs in pre-3.0 UWIN ksh.
-for as_var in ENV MAIL MAILPATH
-do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+# Unset variables that we do not need and cause bugs (e.g. in pre-3.0 UWIN 
ksh).
+# But do not cause bugs in bash 2.01; the "|| exit 1" suppresses any
+# "Segmentation fault" message there.  '((' could trigger a bug in pdksh 
5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset && dnl
+ ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
 done
 PS1='$ '
 PS2='> '
@@ -432,8 +438,22 @@ LANGUAGE=C
 export LANGUAGE
 
 # CDPATH.
-$as_unset CDPATH
-])# AS_SHELL_SANITIZE
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+])# _AS_SHELL_SANITIZE
+
+
+# AS_SHELL_SANITIZE
+# -----------------
+# This is only needed for the sake of Libtool, which screws up royally
+# in its usage of M4sh internals.
+m4_define([AS_SHELL_SANITIZE],
+[_AS_SHELL_SANITIZE
+m4_provide_if([AS_INIT], [],
+[m4_provide([AS_INIT])
+_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
+_AS_DETECT_BETTER_SHELL
+_AS_UNSET_PREPARE
+])])
 
 
 ## ----------------------------- ##
@@ -513,27 +533,24 @@ fi
 
 # _AS_UNSET_PREPARE
 # -----------------
-# AS_UNSET depends upon $as_unset: compute it.
-# Use MAIL to trigger a bug in Bash 2.01;
-# the "|| exit" suppresses the resulting "Segmentation fault" message.
-# Avoid 'if ((', as that triggers a bug in pdksh 5.2.14.
+# Define $as_unset to execute AS_UNSET, for backwards compatibility
+# with older versions of M4sh.
 m4_defun([_AS_UNSET_PREPARE],
-[# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-  as_unset=unset
-else
-  as_unset=false
-fi
+[as_func_unset ()
+{
+  AS_UNSET([$[1]])
+}
+as_unset=as_func_unset
 ])
 
 
-# AS_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
-# --------------------------------------------------
-# Try to unset the env VAR, otherwise set it to
-# VALUE-IF-UNSET-NOT-SUPPORTED.  `as_unset' must have been computed.
+# AS_UNSET(VAR)
+# -------------
+# Unset the env VAR, working around shells that do not allow unsetting
+# a variable that is not already set.  You should not unset MAIL and
+# MAILCHECK, as that triggers a bug in Bash 2.01.
 m4_defun([AS_UNSET],
-[AS_REQUIRE([_AS_UNSET_PREPARE])dnl
-$as_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }])
+[{ AS_LITERAL_IF([$1], [], [eval ])$1=; unset $1;}])
 
 
 
@@ -934,7 +951,7 @@ m4_defun([AS_LINENO_PREPARE], [AS_REQUIRE([_$0])])
 m4_defun([_AS_LINENO_PREPARE],
 [AS_REQUIRE([_AS_CR_PREPARE])dnl
 AS_REQUIRE([_AS_ME_PREPARE])dnl
-_AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])
+_AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])dnl
 _AS_LINENO_WORKS || {
 
   dnl Create $as_me.lineno as a copy of $as_myself, but with $LINENO
@@ -1683,7 +1700,7 @@ m4_define([AS_VAR_POPDEF],
 # for more detail.
 m4_defun([AS_INIT_GENERATED],
 [m4_require([AS_PREPARE])dnl
-AS_SHELL_SANITIZE
+_AS_SHELL_SANITIZE
 _AS_PREPARE])
 
 # AS_INIT
@@ -1693,6 +1710,7 @@ m4_define([AS_INIT],
 [# Wrap our cleanup prior to m4sugar's cleanup.
 m4_wrap([_AS_CLEANUP])
 m4_init
+m4_provide([AS_INIT])
 
 # Forbidden tokens and exceptions.
 m4_pattern_forbid([^_?AS_])
@@ -1701,9 +1719,11 @@ m4_pattern_forbid([^_?AS_])
 m4_divert_text([BINSH], address@hidden:@! /bin/sh])
 m4_divert_text([HEADER-COMMENT],
               address@hidden:@ Generated from __file__ by m4_PACKAGE_STRING.])
-m4_divert_text([M4SH-SANITIZE], [AS_SHELL_SANITIZE])
+m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
 
 # Let's go!
 m4_divert_pop([KILL])[]dnl
 m4_divert_push([BODY])[]dnl
+_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
+AS_REQUIRE([_AS_UNSET_PREPARE])dnl For backwards compatibility.
 ])


hooks/post-receive
--
GNU Autoconf source repository




reply via email to

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