about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-01-27 21:52:25 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2016-01-27 22:10:38 -0800
commit572f8c85ab40c2adf389a33ea6f2f91c4a4fbb30 (patch)
treebf7331f180a4f0ca1dd57be7c1965b7ae36d090b
parent85c185aa895732e80d8865a851d3f7a27bbdcb5e (diff)
downloadzsh-572f8c85ab40c2adf389a33ea6f2f91c4a4fbb30.tar.gz
zsh-572f8c85ab40c2adf389a33ea6f2f91c4a4fbb30.tar.xz
zsh-572f8c85ab40c2adf389a33ea6f2f91c4a4fbb30.zip
37810: repair handling of backslashes and of names starting with "+"/":"/"=" in zparseopts option specs
-rw-r--r--ChangeLog7
-rw-r--r--Src/Modules/zutil.c17
2 files changed, 16 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a8666c1d..e70ed9d80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,14 @@
+2016-01-27  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 37810: Src/Modules/zutil.c: repair handling of backslashes and
+	of names starting with "+"/":"/"=" in zparseopts option specs
+
 2016-01-26  Eric Cook  <llua@gmx.com>
 
 	* 37788: Completion/Zsh/Context/_subscript: fix completion of
 	associative array keys
 
-2016-01-26  Barton E. Schaefer  <schaefer@brasslantern.com>
+2016-01-26  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* 37802: Doc/Zsh/mod_zutil.yo: Clarify zparseopts description.
 
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;