summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/options.c3
-rw-r--r--Src/utils.c15
-rw-r--r--Src/zsh.h1
3 files changed, 16 insertions, 3 deletions
diff --git a/Src/options.c b/Src/options.c
index a2d5e0855..00d552ad5 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -205,7 +205,8 @@ static struct optname optns[] = {
{{NULL, "posixcd", OPT_EMULATE|OPT_BOURNE}, POSIXCD},
{{NULL, "posixidentifiers", OPT_EMULATE|OPT_BOURNE}, POSIXIDENTIFIERS},
{{NULL, "posixjobs", OPT_EMULATE|OPT_BOURNE}, POSIXJOBS},
-{{NULL, "posixtraps", OPT_EMULATE|OPT_BOURNE}, POSIXTRAPS},
+{{NULL, "posixstrings", OPT_EMULATE|OPT_BOURNE}, POSIXSTRINGS},
+{{NULL, "posixtraps", OPT_EMULATE|OPT_BOURNE}, POSIXTRAPS},
{{NULL, "printeightbit", 0}, PRINTEIGHTBIT},
{{NULL, "printexitvalue", 0}, PRINTEXITVALUE},
{{NULL, "privileged", OPT_SPECIAL}, PRIVILEGED},
diff --git a/Src/utils.c b/Src/utils.c
index e788051cf..2e30c176a 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5200,7 +5200,7 @@ getkeystring(char *s, int *len, int how, int *misc)
char *buf, tmp[1];
char *t, *tdest = NULL, *u = NULL, *sstart = s, *tbuf = NULL;
char svchar = '\0';
- int meta = 0, control = 0;
+ int meta = 0, control = 0, ignoring = 0;
int i;
#if defined(HAVE_WCHAR_H) && defined(HAVE_WCTOMB) && defined(__STDC_ISO_10646__)
wint_t wval;
@@ -5623,11 +5623,22 @@ getkeystring(char *s, int *len, int how, int *misc)
if (how & GETKEY_DOLLAR_QUOTE) {
char *t2;
for (t2 = tbuf; t2 < t; t2++) {
+ /*
+ * In POSIX mode, an embedded NULL is discarded and
+ * terminates processing. It just does, that's why.
+ */
+ if (isset(POSIXSTRINGS)) {
+ if (*t2 == '\0')
+ ignoring = 1;
+ if (ignoring)
+ break;
+ }
if (imeta(*t2)) {
*tdest++ = Meta;
*tdest++ = *t2 ^ 32;
- } else
+ } else {
*tdest++ = *t2;
+ }
}
/*
* Reset use of temporary buffer.
diff --git a/Src/zsh.h b/Src/zsh.h
index cc50826e5..1d793741a 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1992,6 +1992,7 @@ enum {
POSIXCD,
POSIXIDENTIFIERS,
POSIXJOBS,
+ POSIXSTRINGS,
POSIXTRAPS,
PRINTEIGHTBIT,
PRINTEXITVALUE,