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

Re: Is quoting of the assigned value needed?



On Fri, 22 Nov 2019 at 11:46, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
>
> 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.

I'm thinking on simplifying the plugin standard's proposed $0
handling, which is currently:

0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"

I.e.: about skipping the quoting. Before I do this is want to be
completely sure that it'll always work.

> Do you want var2 to be an array of split parts of $var1?  In
> that case, do an array assignment.
>
> var2=($var1)
>
> pws
>

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org



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