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

Re: first adventures



On 10/31/2014 12:59 PM, Peter Stephenson wrote:

Strange, I'm getting double posts both sending and receiving.
On Fri, 31 Oct 2014 11:10:54 -0700
Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
One further question, I tried the ' (Q) ' flag to remove quotes, and it
works
as advertised, however trying to print individual array elements fails
whereas
they print fine with the ' (z) 'flag.  Why is that?
They're doing different things.  (Q) really does just remove quotes, it
doesn't split things into elements.  (z) splits things into elements
using the shell's normal rules, but doesn't remove quotes.
Right. Somehow I assumed the breakdown as well, tho there's no reason I should have.
You might be running up against the problem that if you combine them in
the obvious way it doesn't do what you want because the splitting
happens too late.  That's a deliberate rule, it's just not convenient in
this particular case --- there are so many cases for parameter expansion
it's quite impossible to get them all to work in the simplest way.
Sure. I find it unbelievable that anyone can keep any sort of handle on this at all. So much
power, but is it even possible to keep a rigid syntax?
% print -rl ${(Q)${(z)line}}
one two
buckle my shoe
three four

Finally, you've got exactly the right set of arguments as simple strings.
Outstanding. One might wish for something simpler, but if you can nest those things like that, then you could probably get it to do your taxes. zsh seems to always trade away simplicity for power,
but the power is indeed awesome.

But there is always a gotcha:

Using
(( $#functrace == 1 )) && TLC=(${(z)ZSH_DEBUG_CMD})

$ test2 'one \n' "two \n" buckle \n
My unexpanded arguments were: test2 'one \n' "two \n" buckle \n
...and my arguments broken to an array:

two:   'one \n'
three: "two \n"
four:  buckle
five:  \n

Using
(( $#functrace == 1 )) && TLC=(${(Q)${(z)ZSH_DEBUG_CMD}})
}

$ test 'one \n' "two \n" buckle \n
My unexpanded arguments were: test2 one \n two \n buckle n
...and my arguments broken to an array:

two:   one \n
three: two \n
four:  buckle
five:  n             << Why does it remove the backslash?




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