From: "Andrej Borsenkow" <Andrej.Borsenkow@mow.siemens.ru>
To: "Bart Schaefer" <schaefer@candle.brasslantern.com>,
"Zsh hackers list" <zsh-workers@sunsite.auc.dk>,
"Sven Wischnowsky" <wischnow@informatik.hu-berlin.de>
Subject: Let's do it RE: Should we backup this change? RE: Modifier substitutions.
Date: Thu, 4 May 2000 11:02:35 +0400 [thread overview]
Message-ID: <000501bfb596$b9e75290$21c9ca95@mow.siemens.ru> (raw)
In-Reply-To: <1000412145336.ZM12301@candle.brasslantern.com>
>
> The change went in in 6002. It was followed in 6003 by a
> change to allow
> a leading double backslash to escape the delimiter. So all
> you need to
> do is change uses of ${foo/$bar/...} into ${foo/\\$bar/...}
> to avoid the
> confusion. And without 6002, there's no way to build up an anchored
> pattern in a variable (which was Andrej's original complaint).
>
> Also, though I'm the last person to argue for keeping a
> change solely for
> compatibility, bash recognizes the same syntaxes.
>
Unfortunately, it is so inconsistent, that I really suggest to backup
it. Look here:
from Zsh manual (example for ${.../.../...})
foo="twinkle twinkle little star" sub="t*e" rep="spy"
print ${foo//${~sub}/$rep}
print ${(S)foo//${~sub}/$rep}
but
bor@itsrm2% foo=foo
bor@itsrm2% foopat='#foo'
bor@itsrm2% print ${foo/$~foopat/bar}
zsh: bad pattern: #foo
bor@itsrm2% print ${foo/$foopat/bar}
bar
bor@itsrm2% if [[ $foo == $~foopat ]]; then print yes; else print no; fi
zsh: bad pattern: #foo
Looking at the _arguments, there is no ~ flag either:
# ... and add "same" options
while (( $#sopts )); do
lopts=( $lopts ${lopts/$sopts[1]/$sopts[2]} )
shift 2 sopts
done
So, currently
- example in manual is wrong. Or, better said, it _is_ correct because
#foo is invalid pattern - but, then, how _arguments work currently?
Well, they work because there is no metachars in pattern (the only use
is _configure). So, this is wrong anyway.
- any way to fix it will lead to inconsistency - #foo will match `foo'
in replacement, but not anywhere else.
- nobody really expects run native bash scripts with zsh.
- this "anchoring in pattern" is needed in probably 1% of all cases -
forcing use of `\\' in 99%. That is weird. And if anybody needs
anchoring - (#s) is there.
So, my strong suggestion - let's backup it, and for the time being use
(#s) in _configure (I actually do not like these "same" arguments
anyway - it does not work reliably, sigh)
-andrej
next prev parent reply other threads:[~2000-05-04 7:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-06 9:15 Peter Stephenson
2000-04-06 9:32 ` Andrej Borsenkow
2000-04-06 12:49 ` Andrej Borsenkow
2000-04-12 12:26 ` Should we backup this change? " Andrej Borsenkow
2000-04-12 12:34 ` Sven Wischnowsky
2000-04-12 14:53 ` Bart Schaefer
2000-04-12 15:06 ` Andrej Borsenkow
2000-04-12 20:54 ` Peter Stephenson
2000-04-13 6:00 ` Andrej Borsenkow
2000-04-13 8:59 ` Peter Stephenson
2000-05-04 7:02 ` Andrej Borsenkow [this message]
2000-05-04 15:56 ` Let's do it " Peter Stephenson
2000-05-05 13:32 ` PATCH:RE: Let's do it RE: Should we backup this change? RE: Modifiersubstitutions Andrej Borsenkow
2000-05-05 14:26 ` PATCH: substitution anchors Peter Stephenson
2000-05-05 14:52 ` Bart Schaefer
2000-05-05 14:55 ` Andrej Borsenkow
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='000501bfb596$b9e75290$21c9ca95@mow.siemens.ru' \
--to=andrej.borsenkow@mow.siemens.ru \
--cc=schaefer@candle.brasslantern.com \
--cc=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.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).