diff options
author | Barton E. Schaefer <schaefer@zsh.org> | 2016-01-27 21:52:25 -0800 |
---|---|---|
committer | Barton E. Schaefer <schaefer@zsh.org> | 2016-01-27 22:10:38 -0800 |
commit | 572f8c85ab40c2adf389a33ea6f2f91c4a4fbb30 (patch) | |
tree | bf7331f180a4f0ca1dd57be7c1965b7ae36d090b /Src/Modules/zutil.c | |
parent | 85c185aa895732e80d8865a851d3f7a27bbdcb5e (diff) | |
download | zsh-572f8c85ab40c2adf389a33ea6f2f91c4a4fbb30.tar.gz zsh-572f8c85ab40c2adf389a33ea6f2f91c4a4fbb30.tar.xz zsh-572f8c85ab40c2adf389a33ea6f2f91c4a4fbb30.zip |
37810: repair handling of backslashes and of names starting with "+"/":"/"=" in zparseopts option specs
Diffstat (limited to 'Src/Modules/zutil.c')
-rw-r--r-- | Src/Modules/zutil.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index d98028a84..12a4c03e9 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -1745,13 +1745,15 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) for (p = o; *p; p++) { if (*p == '\\' && p[1]) p++; - else if (*p == '+') { - f |= ZOF_MULT; - *p = '\0'; - p++; - break; - } else if (*p == ':' || *p == '=') - break; + else if (p > o) { /* At least one character of option name */ + if (*p == '+') { + f |= ZOF_MULT; + *p = '\0'; + p++; + break; + } else if (*p == ':' || *p == '=') + break; + } } if (*p == ':') { f |= ZOF_ARG; @@ -1789,6 +1791,7 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) p++; *n++ = *p; } + *n = '\0'; if (get_opt_desc(o)) { zwarnnam(nam, "option defined more than once: %s", o); return 1; |