* dumb question about parameter expansion
@ 2012-10-11 11:59 sergio
2012-10-11 12:19 ` Jérémie Roquet
2012-10-11 12:20 ` Frank Terbeck
0 siblings, 2 replies; 3+ messages in thread
From: sergio @ 2012-10-11 11:59 UTC (permalink / raw)
To: zsh-users
Hello.
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 ...
--
sergio.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: dumb question about parameter expansion
2012-10-11 11:59 dumb question about parameter expansion sergio
@ 2012-10-11 12:19 ` Jérémie Roquet
2012-10-11 12:20 ` Frank Terbeck
1 sibling, 0 replies; 3+ messages in thread
From: Jérémie Roquet @ 2012-10-11 12:19 UTC (permalink / raw)
To: sergio; +Cc: zsh-users
Hi Sergio,
2012/10/11 sergio <mailbox@sergio.spb.ru>:
> 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 ...
Unlike other shells, zsh doesn't split unquoted variables by default.
If you want that behaviour, you can either:
- “setopt shwordsplit” to have it by default, or
- use “$l $=o” to have it selectively (the “=” forces the split).
Best regards,
--
Jérémie
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: dumb question about parameter expansion
2012-10-11 11:59 dumb question about parameter expansion sergio
2012-10-11 12:19 ` Jérémie Roquet
@ 2012-10-11 12:20 ` Frank Terbeck
1 sibling, 0 replies; 3+ messages in thread
From: Frank Terbeck @ 2012-10-11 12:20 UTC (permalink / raw)
To: sergio; +Cc: zsh-users
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-11 12:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-11 11:59 dumb question about parameter expansion sergio
2012-10-11 12:19 ` Jérémie Roquet
2012-10-11 12:20 ` Frank Terbeck
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).