From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: ${-str}
Date: Mon, 15 May 2000 16:57:24 +0200 (MET DST) [thread overview]
Message-ID: <200005151457.QAA20907@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Peter Stephenson's message of Mon, 15 May 2000 11:01:24 +0100
Peter Stephenson wrote:
> Sven wrote:
> > Geoff Wing wrote:
> > > :serein% print -lr ${-str}
> > > :569XZfims
> > > % setopt norcs; echo ${-}
> > > 569XZfims
> >
> > Yep. The same as for the other special parameters (`${$foo}').
> > Shouldn't we change this to be an error? Or do we really need this for
> > compatibility?
>
> I think this should be an error. This was never documented behaviour and
> most forms of bad parameter syntax produce complaints.
Hope I haven't missed a special (and allowed) character...
This is done quite lately to be able to catch `${foo[1][2]xxx}'. It
doesn't catch `${}', but since `${:-...}' is valid, that's probably ok.
The other hunks avoid a `unused variable' warning.
Bye
Sven
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.4
diff -u -r1.4 subst.c
--- Src/subst.c 2000/05/08 08:58:37 1.4
+++ Src/subst.c 2000/05/15 14:56:35
@@ -1230,6 +1230,15 @@
if (!inbrace)
break;
}
+ if (inbrace &&
+ (c = *s) != '-' && c != '+' && c != ':' && c != '%' && c != '/' &&
+ c != '=' && c != Equals &&
+ c != '#' && c != Pound &&
+ c != '?' && c != Quest &&
+ c != '}' && c != Outbrace) {
+ zerr("bad substitution", NULL, 0);
+ return NULL;
+ }
if (isarr) {
if (nojoin)
isarr = -1;
@@ -1463,9 +1472,6 @@
}
}
{
- char t = s[-1];
-
- singsub(&s);
#if 0
/*
* This allows # and % to be at the start of
@@ -1473,6 +1479,11 @@
* a bit nasty, and can be done (although
* less efficiently) with anchors.
*/
+
+ char t = s[-1];
+
+ singsub(&s);
+
if (t == '/' && (flags & SUB_SUBSTR)) {
if ((c = *s) == '#' || c == '%') {
flags &= ~SUB_SUBSTR;
@@ -1483,6 +1494,8 @@
s++;
}
}
+#else
+ singsub(&s);
#endif
}
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~2000-05-15 14:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-05-15 14:57 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-05-15 9:28 ${-str} Sven Wischnowsky
2000-05-15 15:02 ` PATCH: ${-str} Peter Stephenson
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=200005151457.QAA20907@beta.informatik.hu-berlin.de \
--to=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).