zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: nohistsubstpattern and :s//
Date: Tue, 07 Jul 2015 17:10:44 +0100	[thread overview]
Message-ID: <20150707171044.396a2900@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <150707084851.ZM9774@torch.brasslantern.com>

On Tue, 7 Jul 2015 08:48:51 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> So with histsubstpattern set it looks like $b is expanded before the
> substitution takes place, but with nohistsubstpattern (the default,
> which is why I never showed the option change in any of my previous
> examples) the expansion happens after the substitution.

Oh, in that case it's perfectly sensible.  The only gotcha is to
remember that because modifiers operate on raw input, which is how they
came to exist in the first place, if you don't want a $ to be active you
need to quote it.

% print ${a:gs/b/\$b/}
a$bc d$be f$bg

Not wanting this effect is probably a sign you should be using

% print ${a//b/$b}

where the rules are roughly "if it quacks like a single word, it's
expanded like a single word", so any expansion is always done (or
suppressed) within the substitution argument, and you get

% print ${a//b/$b}
ac de fg
% print ${a//b/\$b}
a$bc d$be f$bg

pws


  reply	other threads:[~2015-07-07 16:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-04 13:22 Mikael Magnusson
2015-07-05  0:01 ` Bart Schaefer
2015-07-05 10:30   ` Peter Stephenson
2015-07-05 21:11     ` Bart Schaefer
2015-07-06  8:49       ` Peter Stephenson
2015-07-06 20:51         ` Bart Schaefer
2015-07-06 23:04           ` Mikael Magnusson
2015-07-07 11:15           ` Peter Stephenson
2015-07-07 11:54             ` Peter Stephenson
2015-07-07 15:11               ` Bart Schaefer
2015-07-07 15:28                 ` Peter Stephenson
2015-07-07 15:48                   ` Bart Schaefer
2015-07-07 16:10                     ` Peter Stephenson [this message]
2015-07-07 18:10                       ` Bart Schaefer
2015-07-08 14:37                         ` Bart Schaefer
2015-07-07 14:48             ` Bart Schaefer

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=20150707171044.396a2900@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@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).