GNU bug report logs -
#20733
coreutils build problem
Previous Next
Reported by: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Thu, 4 Jun 2015 19:18:02 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #34 received at 20733 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 06/04/2015 02:36 PM, Stephane Chazelas wrote:
> 2015-06-04 14:06:03 -0600, Eric Blake:
> [...]
>> +$ @kbd{cat Makefile}
>> +list =
>> +bad:
>> + @@for arg in $(list); do echo $$arg; done
>> +good:
>> + @@list='$(list)'; for arg in $$list; do echo $$arg; done
> [...]
>
> Another option is to use:
>
> for arg in $${-+$(list)}; do echo $$arg; done
>
>
> That's ${var+value} that expands to value if var is set. $- is
> always set. $0 could also be used instead.
Also could use $$, $? (except $? doesn't always start life set if probed
as the first thing in some shells), $# (except some shells confuse
${varOPvalue} vs. ${#var} when # is used as var). But from a readability
perspective, I don't think that playing golf for the shortest construct
is helpful, when compared to demonstrating something that is more
commonly seen in practice.
Furthermore, your suggestion mishandles a list with a bare }, whereas
mine does not. "make good list='} a'" should output $'}\na\n', not $'a}\n'.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 10 years and 48 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.