summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authordana <dana@dana.is>2018-01-18 15:57:56 -0600
committerPeter Stephenson <p.stephenson@samsung.com>2018-05-14 16:54:19 +0100
commitb066cc3ea99fbb2d5b2c5882d17a679c52f2114b (patch)
treec09b6619e5e98a2e87449be581fe9065013f5e2a /Src
parent449f13a46738ff303e41a8fcad1df850cae721fd (diff)
downloadzsh-b066cc3ea99fbb2d5b2c5882d17a679c52f2114b.tar.gz
zsh-b066cc3ea99fbb2d5b2c5882d17a679c52f2114b.tar.xz
zsh-b066cc3ea99fbb2d5b2c5882d17a679c52f2114b.zip
42297: (e) subscript flag needs extra work with scalars
Diffstat (limited to 'Src')
-rw-r--r--Src/params.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/Src/params.c b/Src/params.c
index 51f6e6d9a..f13093403 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1515,7 +1515,7 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
 	    }
 	}
     } else {
-	if (!v->isarr && !word) {
+	if (!v->isarr && !word && !quote_arg) {
 	    l = strlen(s);
 	    if (a2) {
 		if (!l || *s != '*') {
@@ -1534,9 +1534,23 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
 	    }
 	}
 	if (!keymatch) {
-	    if (quote_arg)
+	    if (quote_arg) {
 		untokenize(s);
-	    else
+		/* Scalar (e) needs implicit asterisk tokens */
+		if (!v->isarr && !word) {
+		    l = strlen(s);
+		    d = (char *) hcalloc(l + 2);
+		    if (a2) {
+			*d = Star;
+			strcpy(d + 1, s);
+		    } else {
+			strcpy(d, s);
+			d[l] = Star;
+			d[l + 1] = '\0';
+		    }
+		    s = d;
+		}
+	    } else
 		tokenize(s);
 	    remnulargs(s);
 	    pprog = patcompile(s, 0, NULL);