From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7106 invoked from network); 16 Feb 2000 15:39:45 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 16 Feb 2000 15:39:45 -0000 Received: (qmail 20860 invoked by alias); 16 Feb 2000 15:39:39 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9763 Received: (qmail 20850 invoked from network); 16 Feb 2000 15:39:38 -0000 Date: Wed, 16 Feb 2000 16:39:36 +0100 (MET) Message-Id: <200002161539.QAA00133@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Wed, 16 Feb 2000 10:57:55 +0000 Subject: Re: help with _match, globcomplete etc. (with a PATCH) 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