]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Document some FreeBSD shell bugs.
authorEric Blake <ebb9@byu.net>
Wed, 14 May 2008 14:25:01 +0000 (08:25 -0600)
committerEric Blake <ebb9@byu.net>
Wed, 14 May 2008 14:25:01 +0000 (08:25 -0600)
* doc/autoconf.texi (Limitations of Builtins) <!>: Mention ! issue
in compound pipe commands.
<export>: Mention difference of exporting an undefined variable.
(Shell Functions): Mention loss of $? in entry to shell functions.
Extracted from the git mailing list.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/autoconf.texi

index dc02724156138c44d0f285bfb9fe3bd537667439..3782a5b55c096f356ded1233c03f75fd80066171 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-05-14  Eric Blake  <ebb9@byu.net>
+
+       Document some FreeBSD shell bugs.
+       * doc/autoconf.texi (Limitations of Builtins) <!>: Mention ! issue
+       in compound pipe commands.
+       <export>: Mention difference of exporting an undefined variable.
+       (Shell Functions): Mention loss of $? in entry to shell functions.
+       Extracted from the git mailing list.
+
 2008-05-13  Stepan Kasal  <kasal@ucw.cz>
 
        Work around MSYS and Cygwin bugs when dealing with trailing space.
index 645cc7b205cf5ef882baac9ab198cd4329db50fe..fd60b7bd59e9a90bb3b7a3dfdaeb460885b58a8b 100644 (file)
@@ -12297,7 +12297,7 @@ by all shells!
 
 Shell functions are considered portable nowadays, though Autoconf still
 does not use them (Autotest does).  However, some pitfalls have to be
-avoided for portable use of shell functions.
+avoided for portable use of shell functions (@pxref{Shell Functions}).
 
 Some ancient systems have quite
 small limits on the length of the @samp{#!} line; for instance, 32
@@ -13704,6 +13704,19 @@ subshell if the last command of that subshell was @code{exit} or
 find a shell that does not exhibit the bug, zsh might be the only shell
 present on the user's machine.
 
+Likewise, the state of @samp{$?} is not reliable when entering a shell
+function.  This has the effect that using a function as the first
+command in a @command{trap} handler can cause problems.
+
+@example
+$ @kbd{bash -c 'foo()@{ echo $?; @}; trap foo 0; (exit 2); exit 2'; echo $?}
+2
+2
+$ @kbd{ash -c 'foo()@{ echo $?; @}; trap foo 0; (exit 2); exit 2'; echo $?}
+0
+2
+@end example
+
 Shell variables and functions may share the same namespace, for example
 with Solaris 10 @command{/bin/sh}:
 
@@ -13762,6 +13775,16 @@ must use @samp{. ./foo}.
 The Unix version 7 shell did not support
 negating the exit status of commands with @command{!}, and this feature
 is still absent from some shells (e.g., Solaris @command{/bin/sh}).
+Other shells, such as FreeBSD @command{/bin/sh} or @command{ash}, have
+bugs when using @command{!} in compound commands:
+
+@example
+$ @kbd{sh -c 'true && ! true | true; echo $?'}
+1
+$ @kbd{ash -c 'true && ! true | true; echo $?'}
+0
+@end example
+
 Shell code like this:
 
 @example
@@ -14138,8 +14161,18 @@ alternately @samp{foo} and @samp{bar}, although they should print only
 @samp{foo} and then a sequence of @samp{bar}s.
 
 Therefore you should @command{export} again each environment variable
-that you update.
+that you update; the export can occur before or after the assignment.
+
+Posix is not clear on whether the @command{export} of an undefined
+variable causes the variable to be defined with the value of an empty
+string, or merely marks any future definition of a variable by that name
+for export.  Various shells behave differently in this regard:
 
+@example
+$ @kbd{sh -c 'export foo; env | grep foo'}
+$ @kbd{ash -c 'export foo; env | grep foo'}
+foo=
+@end example
 
 @item @command{false}
 @c ------------------