[dropping bug-autoconf] On 07/02/2010 10:14 AM, Stefano Lattarini wrote: >> Would you care to prepare a patch? > Here it is (see attachement). I'm not sure I worded it the best way, > though, so suggestions and criticism from native speakers are very > welcome.
Thanks for the initial work. Since both of us are already named as authors of the patch, I didn't see the need to repeat our names in the changelog as the reporter. Then I fixed some wording and condensed the example from 3 down to 2 @example sections. I also minimized quoting to make the examples as compact as possible (even though you are technically correct that "$v" is better than $v in general, it doesn't matter for these specific examples). Here's what I squashed in before pushing. diff --git i/ChangeLog w/ChangeLog index 11de524..1d4af81 100644 --- i/ChangeLog +++ w/ChangeLog @@ -1,12 +1,10 @@ 2010-07-02 Stefano Lattarini <stefano.lattarini AT gmail.com> - Eric Blake <[email protected]> + and Eric Blake <[email protected]> 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. 2010-06-23 Ralf Wildenhues <[email protected]> diff --git i/doc/autoconf.texi w/doc/autoconf.texi index 561fae8..6353f87 100644 --- i/doc/autoconf.texi +++ w/doc/autoconf.texi @@ -16705,43 +16705,28 @@ Limitations of Builtins 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 --------------- -- Eric Blake [email protected] +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
