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

Re: first adventures

On Sat, Nov 1, 2014 at 5:26 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> 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.
> 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?

\n is the same as for example "n", which is one level of quoting,
which (Q) removes. Note that \n is not special to the shell in any way
other than being a quoted letter n. Many builtins parse the _string_
\n as a newline, but \n on the raw input line after parsing into
separate arguments is not the string \n, but the string n.

Mikael Magnusson

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