bug-coreutils
[Top][All Lists]
Advanced

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

bug#20733: [PATCH] doc: mention 'for' syntax issue on older shells


From: Eric Blake
Subject: bug#20733: [PATCH] doc: mention 'for' syntax issue on older shells
Date: Thu, 04 Jun 2015 16:32:48 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

On 06/04/2015 02:59 PM, Eric Blake wrote:

>>> +good:
>>> +   @@list='$(list)'; for arg in $$list; do echo $$arg; done
>> [...]
>>
>> Another option is to use:
>>
>>    for arg in $${-+$(list)}; do echo $$arg; done

> Furthermore, your suggestion mishandles a list with a bare }, whereas
> mine does not.  "make good list='} a'" should output $'}\na\n', not $'a}\n'.

Of course, your version has the benefit of preserving a list that
contains shell quoting (such as list = "a  b" intended to produce a
single string $'a  b') while mine eats it early (producing $'"a' and
$'b"').  But remember that my example is written in a context of
makefiles, where makefile variables tend to be designed to be split at
all whitespace boundaries and do not have an easy mechanism for handling
text that must have specific embedded spacing, and as such are unlikely
to require shell quoting in the first place.

Once again going to show that you have to think about each particular
problem in context (what sort of input will it be processing), rather
than blindly assuming that one formulation will be a catch-all solution.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
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]