about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-08-30 10:15:24 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-08-30 10:15:24 +0000
commitffa18a29ab864c60153601616053e0e3158235e9 (patch)
tree203998e03926b2dd6c607b5088bbdfb46ab26ccd
parenta17bcbc45e4b2b1f3bda883ae429062d58685081 (diff)
downloadzsh-ffa18a29ab864c60153601616053e0e3158235e9.tar.gz
zsh-ffa18a29ab864c60153601616053e0e3158235e9.tar.xz
zsh-ffa18a29ab864c60153601616053e0e3158235e9.zip
zsh-workers/7539
-rw-r--r--Doc/Zsh/expn.yo4
-rw-r--r--Src/subst.c27
2 files changed, 31 insertions, 0 deletions
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 3bc232121..b9af9b83f 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -587,6 +587,10 @@ Quote the resulting words with backslashes.
 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(})' 
diff --git a/Src/subst.c b/Src/subst.c
index 1d739c886..7619c94a9 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -730,6 +730,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
     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 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 		    wantt = 1;
 		    break;
 
+		case '%':
+		    presc = 1;
+		    break;
+
 		default:
 		  flagerr:
 		    zerr("error in flags", NULL, 0);
@@ -1569,6 +1574,28 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 		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) {
 	if (isarr) {
 	    char **ap;