From: Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
To: <zsh-workers@sunsite.dk>
Subject: Patterns quoting in subscript (was: Re: PATCH: Assorted parameter stuff)
Date: Tue, 17 Apr 2001 22:30:21 +0400 (MSD) [thread overview]
Message-ID: <Pine.SV4.4.33.0104172214250.9148-100000@itsrm2.mow.siemens.ru> (raw)
In-Reply-To: <1010415080610.ZM10250@candle.brasslantern.com>
On Sun, 15 Apr 2001, Bart Schaefer wrote:
> The main point of this patch is to address Andrej's message from last August
> ("SourceForge bug id 104052 - case study") and related issues with parsing
> array subscripts. Some other stuff got tweaked in passing.
>
> I'll hold off committing this until a couple of you have applied it and say
> it seems OK. The "make check" tests all pass for me, at least (and it was
> the completion tests, rather than the parameter tests, that gave it the best
> workout).
>
At least one thing has changed (but I consider behaviour broken in
anyway):
bor@itsrm2:~%> foo=(a '?' '\?')
bor@itsrm2:~%> print -r $foo[(r)?]
a
bor@itsrm2:~%> print -r $foo[(r)\?]
?
bor@itsrm2:~%> print -r $foo[(r)\\?]
?
bor@itsrm2:~%> print -r $foo[(r)\\\?]
?
without patch you get:
bor@itsrm2:~%> foo=(a '?' '\?')
bor@itsrm2:~%> print -r $foo[(r)?]
a
bor@itsrm2:~%> print -r $foo[(r)\?]
?
bor@itsrm2:~%> print -r $foo[(r)\\?]
?
bor@itsrm2:~%> print -r $foo[(r)\\\?]
\?
bor@itsrm2:~%> print -r $foo[(r)\\\\?]
\?
bor@itsrm2:~%> print -r $foo[(r)\\\\\?]
\?
etc etc
Both are broken. Without patch you have at least some (albeit completely
unclear) possibility to quote patterns in subscript - with patch even this
one is gone.
I think, we have to decide on how quoting is actually done and finally
implement it. I have very strong inclination to not reinvent te whell and
simply use current quoting rules *including* $~foo (that as response to
another message). We still need special treatment for patterns inside
double quotes (else no subscripting is possible) - with this patch parsing
of subscription is already done in seperate function so it should be
possible.
Suggestion is something like
$foo[()pattern] - is parsed just like a "normal" globbing pattern, taking
in account any quoting. I.e. in $foo[(r)\*$bar] neither ``*'' nor contents
of $bar is taken as pattern.
Special consideration is needed for double quotes. Because normally
"$foo[(r)\?]" is parsed as *two* characters - ``\'' and ``?'', to allow
quoting inside double-quotes extension of quoting rules is needed. I.e.
``\'' should be allowed to quote pattern metacharacters inside of
subscript. I am not sure what impact it possibly have on compatibility ...
OTOH if foo is array, zsh will always parse "$foo[*]" differently from
/bin/sh even in compatibility mode.
-andrej
next prev parent reply other threads:[~2001-04-18 6:34 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-15 8:06 PATCH: Assorted parameter stuff Bart Schaefer
2001-04-17 3:54 ` Example from manual seems broken F. G. Marx
2001-04-17 4:45 ` Bart Schaefer
2001-04-18 6:57 ` PATCH: Assorted parameter stuff Bart Schaefer
2001-04-18 8:44 ` Sven Wischnowsky
2001-04-19 3:57 ` Bart Schaefer
2001-04-19 7:05 ` Sven Wischnowsky
2001-04-19 8:53 ` fpath problem on clean install Andrej Borsenkow
2001-04-19 9:50 ` PATCH: " Sven Wischnowsky
2001-04-19 14:02 ` Andrej Borsenkow
2001-04-19 9:20 ` PATCH: Assorted parameter stuff Andrej Borsenkow
2001-04-19 9:47 ` Bart Schaefer
2001-04-19 9:34 ` Bart Schaefer
2001-04-20 5:20 ` Bart Schaefer
2001-04-17 18:30 ` Andrej Borsenkow [this message]
2001-04-18 7:38 ` Patterns quoting in subscript (was: Re: PATCH: Assorted parameter stuff) Bart Schaefer
2001-04-18 8:10 ` Bart Schaefer
2001-04-18 8:34 ` Andrej Borsenkow
2001-04-18 8:45 ` Andrej Borsenkow
2001-04-18 17:26 ` Bart Schaefer
2001-04-18 20:14 ` 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=Pine.SV4.4.33.0104172214250.9148-100000@itsrm2.mow.siemens.ru \
--to=andrej.borsenkow@mow.siemens.ru \
--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).