From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27213 invoked from network); 30 Aug 1999 09:39:37 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 30 Aug 1999 09:39:37 -0000 Received: (qmail 20811 invoked by alias); 30 Aug 1999 09:39:31 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7539 Received: (qmail 20804 invoked from network); 30 Aug 1999 09:39:31 -0000 Date: Mon, 30 Aug 1999 11:39:27 +0200 (MET DST) Message-Id: <199908300939.LAA20676@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk Subject: PATCH: new parameter flag? Dunno if you like this... This adds the `%' flag to parameter expansion. It makes the result of the expansion undergo prompt expansion. For things like POSTEDIT="${(%):-%b}" day="${${(%):-%W}[1,2]}" Maybe we should finally implement the non-forking form of `$(...)' instead... Bye Sven --- os/subst.c Sun Aug 29 20:00:19 1999 +++ Src/subst.c Sun Aug 29 19:51:01 1999 @@ -730,6 +730,7 @@ int arrasg = 0; int eval = 0; int aspar = 0; + int presc = 0; int nojoin = 0; char inbrace = 0; /* != 0 means ${...}, otherwise $... */ char hkeys = 0; @@ -934,6 +935,10 @@ wantt = 1; break; + case '%': + presc = 1; + break; + default: flagerr: zerr("error in flags", NULL, 0); @@ -1567,6 +1572,28 @@ makelowercase(&val); else makecapitals(&val); + } + } + if (presc) { + int len; + + if (isarr) { + char **ap; + + if (!copied) + aval = arrdup(aval), copied = 1; + ap = aval; + for (; *ap; ap++) { + unmetafy(*ap, &len); + *ap = unmetafy(promptexpand(metafy(*ap, len, META_NOALLOC), + 0, NULL, NULL), &len); + } + } else { + if (!copied) + val = dupstring(val), copied = 1; + unmetafy(val, &len); + val = unmetafy(promptexpand(metafy(val, len, META_NOALLOC), + 0, NULL, NULL), &len); } } if (quotemod) { diff -u od/Zsh/expn.yo Doc/Zsh/expn.yo --- od/Zsh/expn.yo Sun Aug 29 20:00:46 1999 +++ Doc/Zsh/expn.yo Sun Aug 29 19:58:10 1999 @@ -587,6 +587,10 @@ item(tt(Q))( Remove one level of quotes from the resulting words. ) +item(tt(%))( +Expand all tt(%) escapes in the resulting words in the same way as in +prompts (see noderef(Prompt Expansion)). +) 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(})' -- Sven Wischnowsky wischnow@informatik.hu-berlin.de