]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Describe a Solaris /bin/sh bug w.r.t. for loops.
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 2 Jul 2010 16:14:52 +0000 (18:14 +0200)
committerEric Blake <eblake@redhat.com>
Fri, 2 Jul 2010 16:41:49 +0000 (10:41 -0600)
Fix the commit (forgot to 'git add .').

* doc/autoconf.texi (Limitations of Shell Builtins) <for>:
Document a bug of the 'for' builtin in Solaris /bin/sh, w.r.t.
tokens seeming variable assignment in the list of arguments.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
doc/autoconf.texi

index 11de524d6c67ce8e5742973a1c86c341fcf7e5cd..9f5c879d6f97dd6396ad1a90fca1c2e749d7a82b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,10 @@
 2010-07-02  Stefano Lattarini  <stefano.lattarini@gmail.com>
-           Eric Blake  <eblake@redhat.com>
+       and Eric Blake  <eblake@redhat.com>
 
        Describe a Solaris /bin/sh bug w.r.t. for loops.
        * doc/autoconf.texi (Limitations of Shell Builtins) <for>:
        Document a bug of the 'for' builtin in Solaris /bin/sh, w.r.t.
-       tokens seeming variable assignment in the list of arguments.
-       Report and final patch by Stefano Lattarini, useful suggestions
-       by Eric Blake.
+       tokens seeming variable assignment in the list of arguments.
 
 2010-06-23  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
index 561fae8b1850c07bb416a9e0b869ecf77c95d62e..6353f8706c11551e45c25a972cfdd6e8c3221825 100644 (file)
@@ -16705,43 +16705,28 @@ item @samp{$@@}, for more.
 
 In Solaris @command{/bin/sh}, when the list of arguments of a
 @command{for} loop starts with @emph{unquoted} tokens looking like
-variable assignments, the loop is not executed on that tokens:
+variable assignments, the loop is not executed on those tokens:
 
 @example
-$ @kbd{/bin/sh -c 'for v in a=b; do echo "$v"; done'}
-$ @kbd{/bin/sh -c 'for v in a=b d=c; do echo "$v"; done'}
-$ @kbd{/bin/sh -c 'for v in a=b x; do echo "$v"; done'}
+$ @kbd{/bin/sh -c 'for v in a=b c=d x e=f; do echo $v; done'}
 x
+e=f
 @end example
 
 @noindent
-Quoting the "assignment-like" tokens, or preceding them with "normal"
-tokens, solves the problem:
+Thankfully, quoting the assignment-like tokens, or starting the list
+with other tokens (including unquoted variable expansion that results in
+an assignment-like result), avoids the problem, so it is easy to work
+around:
 
 @example
-$ @kbd{/bin/sh -c 'for v in "a=b"; do echo "$v"; done'}
+$ @kbd{/bin/sh -c 'for v in "a=b"; do echo $v; done'}
 a=b
-$ @kbd{/bin/sh -c 'for v in x a=b; do echo "$v"; done'}
-x
-a=b
-$ @kbd{/bin/sh -c 'for v in x a=b d=c; do echo "$v"; done'}
-x
+$ @kbd{/bin/sh -c 'x=a=b; for v in $x c=d; do echo $v; done'}
 a=b
 c=d
 @end example
 
-@noindent
-Luckily enough, the bug is not triggered if the "assignment-like"
-tokens are the results of a variable expansion (even unquoted):
-
-@example
-$ @kbd{/bin/sh -c 'x="a=b"; for v in $x; do echo "$v"; done'}
-a=b
-@end example
-
-@noindent
-So, at least, the bug should be easy to grep for and to avoid.
-
 @anchor{if}
 @item @command{if}
 @c ---------------