From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: help with _match, globcomplete etc. (with a PATCH)
Date: Wed, 16 Feb 2000 16:39:36 +0100 (MET) [thread overview]
Message-ID: <200002161539.QAA00133@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Wed, 16 Feb 2000 10:57:55 +0000
Bart Schaefer wrote:
> } No. Seems like the (e) flag makes the thing be quoted as in double
> } quotes. I.e. with a='${~^arr}*', ${(e)a} gives `[sS] Src/M ../*', but
> } a='${(@)~^arr}' gives what we would have expected. The patch below
> } changes the calls to parsestr() to calls to parse_subst_string() to
> } get that. Hm, should we call that only conditionally, e.g. if the
> } ${(e)...} is not inquotes and has no (@) or something?
>
> My first reaction would be to answer "yes," and a little fooling around
> with 9757 applied seems to bear it out:
>
> a='*'
> print -l "${(e)a}"
>
> Would you really expect to get one file name per line in that case?
First: no. Second: it shouldn't have done globbing -- that should
happen only with ${~...}.
So, next try: always use parsestr() but sometimes turn the `Qstring's
into `String's. This gives:
% a=(a b) b='$a/'
% print -l ${(e)b}
a/
b/
% print -l "${(e)b}"
a b/
% print -l "${(e@)b}"
a/
b/
Which seems quite sensible, right?
Bye
Sven
diff -ru ../z.old/Src/subst.c Src/subst.c
--- ../z.old/Src/subst.c Wed Feb 16 12:40:05 2000
+++ Src/subst.c Wed Feb 16 16:32:12 2000
@@ -694,6 +694,22 @@
return ret < 0 ? -ret : ret;
}
+/* Parsing for the (e) flag. */
+
+static int
+subst_parse_str(char *s, int single)
+{
+ if (!parsestr(s)) {
+ if (!single) {
+ for (; *s; s++)
+ if (*s == Qstring)
+ *s = String;
+ }
+ return 0;
+ }
+ return 1;
+}
+
/* parameter substitution */
#define isstring(c) ((c) == '$' || (char)(c) == String || (char)(c) == Qstring)
@@ -1766,7 +1782,7 @@
if (prenum || postnum)
x = dopadding(x, prenum, postnum, preone, postone,
premul, postmul);
- if (eval && parse_subst_string(x))
+ if (eval && subst_parse_str(x, (qt && !nojoin)))
return NULL;
xlen = strlen(x);
for (tn = firstnode(tl);
@@ -1801,7 +1817,7 @@
if (prenum || postnum)
x = dopadding(x, prenum, postnum, preone, postone,
premul, postmul);
- if (eval && parse_subst_string(x))
+ if (eval && subst_parse_str(x, (qt && !nojoin)))
return NULL;
xlen = strlen(x);
strcatsub(&y, ostr, aptr, x, xlen, NULL, globsubst);
@@ -1816,7 +1832,7 @@
if (prenum || postnum)
x = dopadding(x, prenum, postnum, preone, postone,
premul, postmul);
- if (eval && parse_subst_string(x))
+ if (eval && subst_parse_str(x, (qt && !nojoin)))
return NULL;
if (qt && !*x && isarr != 2)
y = dupstring(nulstring);
@@ -1832,7 +1848,7 @@
if (prenum || postnum)
x = dopadding(x, prenum, postnum, preone, postone,
premul, postmul);
- if (eval && parse_subst_string(x))
+ if (eval && subst_parse_str(x, (qt && !nojoin)))
return NULL;
xlen = strlen(x);
*str = strcatsub(&y, aptr, aptr, x, xlen, fstr, globsubst);
@@ -1851,7 +1867,7 @@
if (prenum || postnum)
x = dopadding(x, prenum, postnum, preone, postone,
premul, postmul);
- if (eval && parse_subst_string(x))
+ if (eval && subst_parse_str(x, (qt && !nojoin)))
return NULL;
xlen = strlen(x);
*str = strcatsub(&y, ostr, aptr, x, xlen, fstr, globsubst);
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~2000-02-16 15:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-02-16 15:39 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-02-17 14:43 Sven Wischnowsky
2000-02-16 10:11 Sven Wischnowsky
2000-02-16 10:57 ` Bart Schaefer
2000-02-16 11:18 ` Oliver Kiddle
2000-02-15 16:08 help with _match, globcomplete etc Sven Wischnowsky
2000-02-15 19:53 ` help with _match, globcomplete etc. (with a PATCH) Oliver Kiddle
2000-02-16 6:47 ` Bart Schaefer
2000-02-16 10:38 ` Oliver Kiddle
2000-02-16 11:52 ` 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=200002161539.QAA00133@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).