summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
authorJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2023-09-13 09:59:42 +0900
committerJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2023-09-13 09:59:42 +0900
commit0eab788437d42afb290637441f88542fc496c307 (patch)
tree1e7b8455db410a3388e7abd59be92f2babbbeeb4 /Src
parent96ce0abf6b7607ca2df64759c495d153132d07bd (diff)
downloadzsh-0eab788437d42afb290637441f88542fc496c307.tar.gz
zsh-0eab788437d42afb290637441f88542fc496c307.zip
52122 + 52129: fix (#) parameter expansion flag
Without the X flag, null string "" is substituted for bad math expression.
Diffstat (limited to 'Src')
-rw-r--r--Src/subst.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 14947ae36..d68159227 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1489,11 +1489,18 @@ subst_parse_str(char **sp, int single, int err)
static char *
substevalchar(char *ptr)
{
- zlong ires = mathevali(ptr);
+ zlong ires;
int len = 0;
+ int saved_errflag = errflag;
- if (errflag)
- return NULL;
+ errflag = 0;
+ ires = mathevali(ptr);
+
+ if (errflag) { /* not a valid numerical expression */
+ errflag |= saved_errflag;
+ return noerrs ? dupstring(""): NULL;
+ }
+ errflag |= saved_errflag;
#ifdef MULTIBYTE_SUPPORT
if (isset(MULTIBYTE) && ires > 127) {
/* '\\' + 'U' + 8 bytes of character + '\0' */