zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: first adventures
Date: Fri, 31 Oct 2014 21:26:01 -0700	[thread overview]
Message-ID: <545460D9.2090804@eastlink.ca> (raw)
In-Reply-To: <20141031195903.167d3e05@pws-pc.ntlworld.com>

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@eastlink.ca> 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?



  reply	other threads:[~2014-11-01  4:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <544D2D6F.8030505@eastlink.ca>
     [not found] ` <20141026175257.2611487b@pws-pc.ntlworld.com>
     [not found]   ` <544FD6DD.7010806@eastlink.ca>
     [not found]     ` <141028210510.ZM10784@torch.brasslantern.com>
     [not found]       ` <54510A96.20009@eastlink.ca>
     [not found]         ` <141029134624.ZM15681@torch.brasslantern.com>
     [not found]           ` <545178DF.1040600@eastlink.ca>
     [not found]             ` <141029210738.ZM15833@torch.brasslantern.com>
     [not found]               ` <5452ED18.7070208@eastlink.ca>
     [not found]                 ` <141030195906.ZM30057@torch.brasslantern.com>
2014-10-31 18:10                   ` Ray Andrews
2014-10-31 19:59                     ` Peter Stephenson
2014-11-01  4:26                       ` Ray Andrews [this message]
2014-11-01  7:51                         ` Mikael Magnusson
2014-11-01 16:35                           ` Ray Andrews
2014-11-01 18:40                             ` Peter Stephenson
2014-11-01 20:24                               ` Ray Andrews
2014-11-01 21:11                                 ` Peter Stephenson
2014-11-01 23:23                                   ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=545460D9.2090804@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).