Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: extra arguments inserted by glob thinger e:: get sorted afterwards



On 8 February 2010 13:44, Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx> wrote:
> JÃrg Sommer wrote:
> [...]
>>> % print -- *.sh(oNe:'reply=(-f $REPLY)':)
>>> -f zmpc.sh -f ifs.sh -f test.sh -f script_pandora.sh
>>
>> Why not use $^?
>>
>> % print -- -f\ ${(f)^"$(print -l /bin/ls*)"}
>> -f /bin/ls -f /bin/lsmod
>
> Because:
> % print -l -- -f\ ${(f)^"$(print -l /bin/ls*)"}
> -f /bin/ls
> -f /bin/lsmod
>
> "-f /bin/ls" would be one word to the shell.

And also because:
# touch /bin/ls'
fail'
% print -- -f\ ${(f)^"$(print -l /bin/ls*)"}
-f /bin/ls
-f /bin/ls
-f fail
-f /bin/lsmod

$() is almost impossible to get right wrt quoting.
print -l -- -f\ ${(0)^"$(printf '%s\0' /bin/ls*)"} probably works a
bit better, but of course it's still useless since the -f is not a
separate parameter.

As an aside, is "$(echo a b c)" the only way to get an 'inline' array
in a ${} expression? I sometimes want to use a glob qualifier on a
middle part of a path but then I need to use temp arrays (and I'd
rather not use $() there).

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author