From 22af58bf2b5b695cdbfaf4b7cdf82bb09136860b Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 3 Jun 2011 22:03:43 +0000 Subject: 29451: ${##stuff} removes stuff from the head of $# --- Src/subst.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Src/subst.c') diff --git a/Src/subst.c b/Src/subst.c index f9c48404b..314489e49 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -2080,7 +2080,16 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) || (cc = s[1]) == '*' || cc == Star || cc == '@' || cc == '?' || cc == Quest || cc == '$' || cc == String || cc == Qstring - || cc == '#' || cc == Pound + /* + * Me And My Squiggle: + * ${##} is the length of $#, but ${##foo} + * is $# with a "foo" removed from the start. + * If someone had defined the *@!@! language + * properly in the first place we wouldn't + * have this nonsense. + */ + || ((cc == '#' || cc == Pound) && + s[2] == Outbrace) || cc == '-' || (cc == ':' && s[2] == '-') || (isstring(cc) && (s[2] == Inbrace || s[2] == Inpar)))) { getlen = 1 + whichlen, s++; -- cgit v1.2.3 From 03b0edaa639156f819b7d79a6d1c538047d55ae6 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 6 Jun 2011 09:08:21 +0000 Subject: 29462: fix warning --- ChangeLog | 7 ++++++- Src/subst.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'Src/subst.c') diff --git a/ChangeLog b/ChangeLog index 64971a413..4777dde22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-06-06 Peter Stephenson + + * 29462: Src/subst.c: fix warning with some compilers (code was + already safe). + 2011-06-05 Clint Adams * unposted: Functions/Zle/move-line-in-buffer: clean @@ -14970,5 +14975,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5364 $ +* $Revision: 1.5365 $ ***************************************************** diff --git a/Src/subst.c b/Src/subst.c index 314489e49..e8a181129 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -2848,7 +2848,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) char *check_offset = check_colon_subscript(s, &check_offset2); if (check_offset) { zlong offset = mathevali(check_offset); - zlong length; + zlong length = 0; int length_set = 0; int offset_hack_argzero = 0; if (errflag) -- cgit v1.2.3 From ad29258c8c2785796d3149c6c230e55d9debc82b Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 1 Jul 2011 15:23:01 +0000 Subject: 29530: ${...?...} shouldn't cause an error with NO_EXEC option --- ChangeLog | 7 ++++++- Src/subst.c | 28 +++++++++++++++------------- Test/E01options.ztst | 4 ++++ 3 files changed, 25 insertions(+), 14 deletions(-) (limited to 'Src/subst.c') diff --git a/ChangeLog b/ChangeLog index e4016aa3a..c2f1fd8a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-07-01 Peter Stephenson + + * 29530: Src/subst.c, Test/E01options.ztst: ${..?..} shouldn't + cause an error with NO_EXEC option. + 2011-07-01 Frank Terbeck * 29518: Completion/Unix/Command/_git: Fall back to file @@ -15077,5 +15082,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5389 $ +* $Revision: 1.5390 $ ***************************************************** diff --git a/Src/subst.c b/Src/subst.c index e8a181129..1b0097001 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -2715,19 +2715,21 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) case '?': case Quest: if (vunset) { - *idend = '\0'; - zerr("%s: %s", idbeg, *s ? s : "parameter not set"); - if (!interact) { - if (mypid == getpid()) { - /* - * paranoia: don't check for jobs, but there shouldn't - * be any if not interactive. - */ - stopmsg = 1; - zexit(1, 0); - } else - _exit(1); - } + if (isset(EXECOPT)) { + *idend = '\0'; + zerr("%s: %s", idbeg, *s ? s : "parameter not set"); + if (!interact) { + if (mypid == getpid()) { + /* + * paranoia: don't check for jobs, but there + * shouldn't be any if not interactive. + */ + stopmsg = 1; + zexit(1, 0); + } else + _exit(1); + } + } return NULL; } break; diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 4b53840c6..1bbfdbda1 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -353,6 +353,10 @@ echo *NonExistentFile*) 0:NO_EXEC option should not do globbing + (setopt noexec + echo ${unset_var?Not an error}) +0:NO_EXEC should not test for unset variables + setopt NO_eval_lineno eval 'print $LINENO' setopt eval_lineno -- cgit v1.2.3 From 85b00bb0f7c60b9f4da5261633221cc200a0ab7f Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 17 Aug 2011 20:26:05 +0000 Subject: 29703: crash when failing to parse process substitutions --- ChangeLog | 4 +++- Src/exec.c | 10 +++++++++- Src/subst.c | 2 ++ Test/D03procsubst.ztst | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) (limited to 'Src/subst.c') diff --git a/ChangeLog b/ChangeLog index 76eb0d1dc..fa352b0e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2011-08-17 Peter Stephenson + * 29703: Src/exec.c, Src/subst.c, Test/D03procsubst.ztst: + * users/16253, users/16255: Src/utils.c, Test/D04parameter.ztst: A nulstring should be split like an empty string. @@ -15297,5 +15299,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5438 $ +* $Revision: 1.5439 $ ***************************************************** diff --git a/Src/exec.c b/Src/exec.c index a9164bc64..3c51a3d42 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3755,7 +3755,15 @@ parsecmd(char *cmd, char **eptr) for (str = cmd + 2; *str && *str != Outpar; str++); if (!*str || cmd[1] != Inpar) { - zerr("oops."); + /* + * This can happen if the expression is being parsed + * inside another construct, e.g. as a value within ${..:..} etc. + * So print a proper error message instead of the not very + * useful but traditional "oops". + */ + char *errstr = dupstrpfx(cmd, 2); + untokenize(errstr); + zerr("unterminated `%s...)'", errstr); return NULL; } *str = '\0'; diff --git a/Src/subst.c b/Src/subst.c index 1b0097001..66e0bbe77 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -162,6 +162,8 @@ stringsubst(LinkList list, LinkNode node, int ssub, int asssub) subst = getproc(str, &rest); /* <(...) or >(...) */ else subst = getoutputfile(str, &rest); /* =(...) */ + if (errflag) + return NULL; if (!subst) subst = ""; diff --git a/Test/D03procsubst.ztst b/Test/D03procsubst.ztst index 37a67630f..602b1da15 100644 --- a/Test/D03procsubst.ztst +++ b/Test/D03procsubst.ztst @@ -84,3 +84,7 @@ ) 0:=(...) preceded by other stuff has no special effect >everything,=(here is left),alone + + print something=${:-=(echo 'C,D),(F,G)'} +1: Graceful handling of bad substitution in enclosed context +?(eval):1: unterminated `=(...)' -- cgit v1.2.3 From 79dd64749622cd08c7087e8170906a030e350824 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 28 Nov 2011 09:48:22 +0000 Subject: Ismail Dönmez: 29920: NO_EXEC problem with arithmetic substitution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 7 ++++++- Src/subst.c | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'Src/subst.c') diff --git a/ChangeLog b/ChangeLog index 8ae674ece..72bfe8e0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-28 Peter Stephenson + + * Ismail Dönmez: 29920: Src/Subst.c: error with arithmetic + substitution with NO_EXEC. + 2011-11-25 Peter Stephenson * unposted: Config/version.mk: 4.3.12-test-3. @@ -15618,5 +15623,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5507 $ +* $Revision: 1.5508 $ ***************************************************** diff --git a/Src/subst.c b/Src/subst.c index 66e0bbe77..4e8ed721d 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -247,7 +247,10 @@ stringsubst(LinkList list, LinkNode node, int ssub, int asssub) if (endchar == Outpar && str2[1] == '(' && str[-2] == ')') { /* Math substitution of the form $((...)) */ str[-2] = '\0'; - str = arithsubst(str2 + 2, &str3, str); + if (isset(EXECOPT)) + str = arithsubst(str2 + 2, &str3, str); + else + strncpy(str3, str2, 1); setdata(node, (void *) str3); continue; } -- cgit v1.2.3