From: Derek Peschel <dpeschel@eskimo.com>
To: zsh-workers@sunsite.dk
Subject: Re: parameter substitution won't double backslashes in values
Date: Fri, 8 Feb 2002 01:29:44 -0800 [thread overview]
Message-ID: <20020208012944.A8380@eskimo.eskimo.com> (raw)
In-Reply-To: <Pine.BSF.4.40.0202072033570.37987-100000@brasslantern.com>; from schaefer@brasslantern.com on Thu, Feb 07, 2002 at 09:00:05PM +0000
On Thu, Feb 07, 2002 at 09:00:05PM +0000, Bart Schaefer wrote:
> On Thu, 7 Feb 2002, Derek Peschel wrote:
> > Maybe my explanation was too complicated, or probably you missed the
> > beginning of the thread.
>
> I saw the beginning of the thread, and I saw Sven's answer, which didn't
> seem to bear repeating, so I was responding only to the parenthetical
> comment about backspace changing to "\b". As Sven's answer apparently
> does bear repeating:
Thanks for clearing that up. I apologize if I was a bit rude. Sven's
answer is the most practical for my needs.
> However, (q) will also insert a backslash in front of any other character
> that is special to the shell parser. If you want *only* to double all the
> backslashes, you need one of:
>
> zsh% print -r ${x//\\\/\\\\}
> a\\bc
> zsh% print -r ${x:gs/\\/\\\\\\\\}
> a\\bc
>
> The reason you need three backslashes as the pattern in the first case is
> rather complicated and could possibly be considered a bug; it has to do
> with using glob-pattern interpretation in ${x//...}. The reason you need
I was afraid of this... parameter expansion is obviously a complicated
operation. (I took "BUG? - " out of the subject because I haven't found
a problem that I know how to identify or fix. But not being able to
understand the syntax is somewhat of a bug in itself.)
For example, I only have a guess as to why these examples do what they do.
> x="/usr/home/dpeschel"
> print ${(q)x//t}
/usr/home/dpeschel
> print ${(q)x/\/t}
t/usr/home/dpeschel
The first example has "//" (as in global search-and-replace) followed by
a search pattern of "t", without the "/" to delimit the replacement pattern
or the pattern itself.
The second example has "/" (as in non-global search-and-replace) followed
by an empty search pattern, then "\/" which ends the search pattern,
then a replacement pattern of "t".
Is this true?
-- Derek
next prev parent reply other threads:[~2002-02-08 9:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-07 4:39 BUG? - 4.0.2 - " Derek Peschel
2002-02-07 10:33 ` Peter Stephenson
2002-02-07 13:19 ` Derek Peschel
2002-02-07 19:20 ` Bart Schaefer
2002-02-07 20:22 ` Derek Peschel
2002-02-07 21:00 ` Bart Schaefer
2002-02-08 9:29 ` Derek Peschel [this message]
2002-02-08 21:35 ` Bart Schaefer
2002-02-07 10:44 ` BUG? - 4.0.2 - " Sven Wischnowsky
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=20020208012944.A8380@eskimo.eskimo.com \
--to=dpeschel@eskimo.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).