From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: parameter and quoting (was: Re: Completion problems.)
Date: Thu, 5 Aug 1999 16:26:40 +0200 (MET DST) [thread overview]
Message-ID: <199908051426.QAA17397@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Peter Stephenson's message of Thu, 05 Aug 1999 15:18:05 +0200
Peter Stephenson wrote:
> Sven Wischnowsky wrote:
> > Ah, right, hadn't thought about patterns (ahem)... "${a%'}" reports
> > the error.
> >
> > Hm. Should the proposed new flag apply to those, too, and change the
> > current behaviour to not report the error or should the current
> > behaviour of (Q) be changed?
>
> The first possibility sounds sensible to me, too, since ksh allows
> you to do
Fine. This adds the (X) flag to turn on error-reporting. Both `e' and
`E' were already taken, I could have used `w' or `W' for `warning' or
something like that, but that isn't really correct. Other free
characters are: DGHJKTVWYZabcdghmnuwxyz -- any suggestions, or is `X'
acceptable?
This also makes `:Q' work for history expansions. I always forget that
history doesn't use modify().
Then Andrej Borsenkow wrote:
> Unfortunately, Single UNIX requires, that quotes be matched. This is from the
> description of double-quotes:
>
> ==
> Within the string of characters from an enclosed ${ to the matching "}", an even
> number of unescaped double-quotes or single-quotes, if any, must occur.
> ==
>
> It means, that preceding example MUST be
>
> echo "${a%\'}"
Damn, I just had the patch... but even if we decide to follow the
standard and not ksh here, it will be easier with this patch.
Bye
Sven
diff -u os/hist.c Src/hist.c
--- os/hist.c Thu Aug 5 14:19:19 1999
+++ Src/hist.c Thu Aug 5 16:16:43 1999
@@ -577,6 +577,18 @@
case 'q':
quote(&sline);
break;
+ case 'Q':
+ {
+ int one = noerrs, oef = errflag;
+
+ noerrs = 1;
+ parse_subst_string(sline);
+ noerrs = one;
+ errflag = oef;
+ remnulargs(sline);
+ untokenize(sline);
+ }
+ break;
case 'x':
quotebreak(&sline);
break;
diff -u os/subst.c Src/subst.c
--- os/subst.c Thu Aug 5 14:19:21 1999
+++ Src/subst.c Thu Aug 5 16:10:54 1999
@@ -721,7 +721,7 @@
int flnum = 0;
int sortit = 0, casind = 0;
int casmod = 0;
- int quotemod = 0;
+ int quotemod = 0, quoteerr = 0;
char *sep = NULL, *spsep = NULL;
char *premul = NULL, *postmul = NULL, *preone = NULL, *postone = NULL;
char *replstr = NULL; /* replacement string for /orig/repl */
@@ -830,6 +830,9 @@
case 'Q':
quotemod = -1;
break;
+ case 'X':
+ quoteerr = 1;
+ break;
case 'e':
eval = 1;
@@ -1388,12 +1391,23 @@
case '#':
case Pound:
case '/':
- if (qt)
- if (parse_subst_string(s)) {
+ if (qt) {
+ int one = noerrs, oef = errflag, haserr;
+
+ if (!quoteerr)
+ noerrs = 1;
+ haserr = parse_subst_string(s);
+ noerrs = one;
+ if (!quoteerr) {
+ errflag = oef;
+ if (haserr)
+ tokenize(s);
+ } else if (haserr || errflag) {
zerr("parse error in ${...%c...} substitution",
NULL, s[-1]);
return NULL;
}
+ }
{
char t = s[-1];
@@ -1567,16 +1581,22 @@
for (; *ap; ap++)
*ap = bslashquote(*ap, NULL, 0);
else {
- int one = noerrs, oef = errflag;
+ int one = noerrs, oef = errflag, haserr = 0;
- noerrs = 1;
+ if (!quoteerr)
+ noerrs = 1;
for (; *ap; ap++) {
- parse_subst_string(*ap);
+ haserr |= parse_subst_string(*ap);
remnulargs(*ap);
untokenize(*ap);
}
noerrs = one;
- errflag = oef;
+ if (!quoteerr)
+ errflag = oef;
+ else if (haserr || errflag) {
+ zerr("parse error in parameter value", NULL, 0);
+ return NULL;
+ }
}
} else {
if (!copied)
@@ -1584,12 +1604,18 @@
if (quotemod > 0)
val = bslashquote(val, NULL, 0);
else {
- int one = noerrs, oef = errflag;
+ int one = noerrs, oef = errflag, haserr;
- noerrs = 1;
- parse_subst_string(val);
+ if (!quoteerr)
+ noerrs = 1;
+ haserr = parse_subst_string(val);
noerrs = one;
- errflag = oef;
+ if (!quoteerr)
+ errflag = oef;
+ else if (haserr || errflag) {
+ zerr("parse error in parameter value", NULL, 0);
+ return NULL;
+ }
remnulargs(val);
untokenize(val);
}
diff -u od/Zsh/expn.yo Doc/Zsh/expn.yo
--- od/Zsh/expn.yo Thu Aug 5 14:19:13 1999
+++ Doc/Zsh/expn.yo Thu Aug 5 16:17:48 1999
@@ -587,6 +587,11 @@
item(tt(Q))(
Remove one level of quotes from the resulting words.
)
+item(tt(X))(
+With this flag parsing errors occuring with the tt(Q) flag or the
+pattern matching forms such as `tt(${)var(name)tt(#)var(pattern)tt(})'
+are reported. Without the flag they are silently ignored.
+)
item(tt(c))(
With tt(${#)var(name)tt(}), count the total number of characters in an array,
as if the elements were concatenated with spaces between them.
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-08-05 14:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-08-05 14:26 Sven Wischnowsky [this message]
1999-08-05 14:41 ` Andrej Borsenkow
1999-08-05 16:24 ` Bart Schaefer
-- strict thread matches above, loose matches on Subject: below --
1999-08-06 7:14 Sven Wischnowsky
1999-08-05 12:53 Sven Wischnowsky
1999-08-05 13:18 ` Peter Stephenson
1999-08-05 14:22 ` Andrej Borsenkow
1999-08-05 12:19 Sven Wischnowsky
1999-08-05 12:05 ` Peter Stephenson
1999-08-05 16:20 ` 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=199908051426.QAA17397@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).