zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: b='${a//"/}' and ${(e)b}
Date: Sat, 10 May 2008 10:12:41 -0700	[thread overview]
Message-ID: <080510101241.ZM6894@torch.brasslantern.com> (raw)
In-Reply-To: <20080510123843.GA5560@sc.homeunix.net>

On May 10,  1:38pm, Stephane Chazelas wrote:
}
} $ a='a"b'
} $ b='${a//"/}'
} $ echo ${(e)b}

(etc.)

If you use

$ echo ${(Xe)b}

Then you'll see that zsh burps "parse error" on nearly every one of those
expressions.  Without the (X) flag the error is silently ignored and the
expansion returns nothing.  (Perhaps zmv should use (X).)

Now, as to why it's hard to quote a double quote within a // replacement
when using the (e) flag, I'm not sure what to say except that the parsing
rules for all those nested levels of sometimes-implicit quoting get a bit
arcane.

} How would I do?

$ c='"'
$ b='${a//$c/}'
$ print ${(Xe)b}

Which does work for zmv:

$ zmv -n '*"*' '${f//$c/}'
mv -- a\"b ab

Or you can do this:

$ zmv -n '*"*' '$f:gs/"//'
mv -- a\"b ab

The parsing rules for :s are a lot simpler than those for ${...}.


  reply	other threads:[~2008-05-10 17:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-10 12:38 Stephane Chazelas
2008-05-10 17:12 ` Bart Schaefer [this message]
2008-05-11 16:10   ` Stephane Chazelas
2008-05-10 21:02 ` [PATCH] zmv (Was: b='${a//"/}' and ${(e)b}) Stephane Chazelas

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=080510101241.ZM6894@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.dk \
    /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).