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

Re: Parameter Expansion questions



David R. Favor wrote:
>In zsh, I'm having a challenge deciphering the manual about parameter
>expansion options. I've tried the following, without success. All fragments
>set $IFS=: before expansion:
>
>   export SH_WORD_SPLIT     // explicit 'set SH_WORD_SPLIT'
>   splitpath=$*

zsh doesn't perform field splitting on the RHS of scalar variable
assignments.  Try "echo $*" under equivalent circumstances.

>I did figure out that this works:
>
>   splitpath=${buf:gs/:/ /}

That's doing a substitution, rather than field splitting.  Since the
effect you're asking for is actually a substitution, rather than field
splitting (since you're just joining up the fields again anyway), this
is logically the correct thing to do.

OTOH, I suspect that you *really* want to be using an array parameter.
$path is an array version of $PATH, so you don't even need to do the
splitting manually in that case.

-zefram



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