autoconf-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Describe a Solaris /bin/sh bug w.r.t. for loops.


From: Eric Blake
Subject: Re: [PATCH] Describe a Solaris /bin/sh bug w.r.t. for loops.
Date: Fri, 02 Jul 2010 10:37:31 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.2 Thunderbird/3.0.5

[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  <address@hidden>
+       and Eric Blake  <address@hidden>

        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  <address@hidden>

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

address@hidden
-Luckily enough, the bug is not triggered if the "assignment-like"
-tokens are the results of a variable expansion (even unquoted):
-
address@hidden
-$ @kbd{/bin/sh -c 'x="a=b"; for v in $x; do echo "$v"; done'}
-a=b
address@hidden example
-
address@hidden
-So, at least, the bug should be easy to grep for and to avoid.
-
 @anchor{if}
 @item @command{if}
 @c ---------------

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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