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

Re: dumb question about parameter expansion



sergio wrote:
> Looks like it's dumb question, but I can't understand this.
>
> % zsh -f
> % l='ls'
> % o='-l -h'
> % $l $o
> ls: invalid option -- ' '
> Try `ls --help' for more information.
>
> % ls -l -h
> total 512
> drwxr-x---  2 sergio sergio ...

Zsh doesn't do wordsplitting of unquoted parameters (at least not by
default, which is a good thing[tm]). Use an array instead:

% o=(-l -h)
% ls $o

See <http://zshwiki.org/home/scripting/paramexp> as well.

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925



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