[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] document shell function problems
From: |
Paolo Bonzini |
Subject: |
[PATCH] document shell function problems |
Date: |
Fri, 05 Oct 2007 11:17:19 +0200 |
User-agent: |
Thunderbird 2.0.0.6 (Macintosh/20070728) |
Here is what I could gather from reports on address@hidden In
particular http://www.mail-archive.com/address@hidden/msg15966.html
suggested me the following minimal reproducer
test -n "${ZSH_VERSION+set}" && emulate sh
failure1 () {
(exit 1)
echo $?
}
failure2 () {
(exit 1)
}
failure1
failure2
echo $?
yielding two 1's on bash and two 0's on zsh.
Ok to apply?
Paolo
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index bd67ab1..4a13ba8 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -11264,10 +11264,20 @@ 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}).
-You should not use shell functions, aliases, negated character
-classes, or other features that are not found in all Bourne-compatible
-shells; restrict yourself to the lowest common denominator. Even
address@hidden is not supported by all shells!
+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!
+
+Shell functions are considered portable nowadays, though Autoconf
+still does not use them (Autotest does). However, inside a shell
+function you should not be using @code{$?} to check the return code
+of a subshell invocation; in general, since the caller of a shell
+function might look at the function's return code, make sure that the
+last statement of a shell function does not invoke a subshell.
+Using subshells triggers bugs in zsh 4.x; while Autoconf tries
+to find a shell that does not exhibit the bug, zsh might be the
+only shell present on the user's machine.
Some ancient systems have quite
small limits on the length of the @samp{#!} line; for instance, 32