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

Re: Is quoting of the assigned value needed?



On Fri, 2019-11-22 at 03:03 +0100, Sebastian Gniazdowski wrote:
> Hello,
> SH_WORD_SPLIT doesn't seem to cause any effects in this context:
> 
> setopt SH_WORD_SPLIT
> var1="a   b"
> var2=$var1
> print "$var2"
> 
> Output: a   b

Correct, there's no splitting there: you've got a quoted assignment, a
single word assignment, and quoted output.

What you should be doing depends on what you're trying to do, which you
don't say.  Do you want var2 to be an array of split parts of $var1?  In
that case, do an array assignment.

var2=($var1)

pws



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