From 3b5d77d819e1b7a94c4b14d69bddb2dddf8605ff Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Sun, 12 Oct 2014 17:52:11 +0100
Subject: 33423: expand ${(p)...} to allow ${(ps.$param.)...}
---
Src/subst.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
(limited to 'Src/subst.c')
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);
--
cgit 1.4.1