summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2014-10-12 17:52:11 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2014-10-12 17:52:11 +0100
commit3b5d77d819e1b7a94c4b14d69bddb2dddf8605ff (patch)
tree226e161923542e6c1bf983a8350b65494c4bda41 /Src
parent521313b4b95817c9144ab43ab121da934f99bd51 (diff)
downloadzsh-3b5d77d819e1b7a94c4b14d69bddb2dddf8605ff.tar.gz
zsh-3b5d77d819e1b7a94c4b14d69bddb2dddf8605ff.tar.xz
zsh-3b5d77d819e1b7a94c4b14d69bddb2dddf8605ff.zip
33423: expand ${(p)...} to allow ${(ps.$param.)...}
Diffstat (limited to 'Src')
-rw-r--r--Src/subst.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 1aa9b982e..61aa1c136 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1385,12 +1385,23 @@ static char *
 untok_and_escape(char *s, int escapes, int tok_arg)
 {
     int klen;
-    char *dst;
+    char *dst = NULL;
 
-    untokenize(dst = dupstring(s));
-    if (escapes) {
-	dst = getkeystring(dst, &klen, GETKEYS_SEP, NULL);
-	dst = metafy(dst, klen, META_HREALLOC);
+    if (escapes && (*s == String || *s == Qstring) && s[1]) {
+	char *pstart = s+1, *pend;
+	for (pend = pstart; *pend; pend++)
+	    if (!iident(*pend))
+		break;
+	if (!*pend) {
+	    dst = dupstring(getsparam(pstart));
+	}
+    }
+    if (dst == NULL) {
+	untokenize(dst = dupstring(s));
+	if (escapes) {
+	    dst = getkeystring(dst, &klen, GETKEYS_SEP, NULL);
+	    dst = metafy(dst, klen, META_HREALLOC);
+	}
     }
     if (tok_arg)
 	shtokenize(dst);