diff options
author | dana <dana@dana.is> | 2018-01-18 15:57:56 -0600 |
---|---|---|
committer | Peter Stephenson <p.stephenson@samsung.com> | 2018-05-14 16:54:19 +0100 |
commit | b066cc3ea99fbb2d5b2c5882d17a679c52f2114b (patch) | |
tree | c09b6619e5e98a2e87449be581fe9065013f5e2a | |
parent | 449f13a46738ff303e41a8fcad1df850cae721fd (diff) | |
download | zsh-b066cc3ea99fbb2d5b2c5882d17a679c52f2114b.tar.gz zsh-b066cc3ea99fbb2d5b2c5882d17a679c52f2114b.tar.xz zsh-b066cc3ea99fbb2d5b2c5882d17a679c52f2114b.zip |
42297: (e) subscript flag needs extra work with scalars
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | Src/params.c | 20 | ||||
-rw-r--r-- | Test/D06subscript.ztst | 16 |
3 files changed, 41 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog index 50a32653d..deac58d68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2018-05-14 Peter Stephenson <p.stephenson@samsung.com> + + * 42297: dana: Src/params.c, Test/D06subscript.ztst: (e) + subscript needs extra work with scalars. + + * 42234: Stephane: Src/signals.c: don't kill a process that's + already exited when killing a job. + 2018-05-13 Oliver Kiddle <okiddle@yahoo.co.uk> * 42488: Src/Modules/mathfunc.c, Src/builtin.c, Src/math.c, 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); diff --git a/Test/D06subscript.ztst b/Test/D06subscript.ztst index f0a858b1c..3ea7fb7e4 100644 --- a/Test/D06subscript.ztst +++ b/Test/D06subscript.ztst @@ -273,3 +273,19 @@ print ${string[1,twoarg(1,4)]} 0:Commas inside parentheses do not confuse subscripts >abc + + string='foobarbaz foob?rbaz foob?rbaz' + print $string[(i)b?r] $string[(I)b?r] + print $string[(r)b?r] $string[(R)b?r] + print $string[(r)b?r,(R)b?r] + print $string[(ei)b?r] $string[(eI)b?r] + print $string[(er)b?r] $string[(eR)b?r] + print $string[(er)b?r,(eR)b?r] +0:Pattern handling with scalars +F:Regression test for workers/42297 +>4 24 +>b b +>barbaz foob?rbaz foob?r +>14 24 +>b b +>b?rbaz foob?r |