summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2016-11-24 06:57:52 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2016-11-28 07:16:38 +0000
commita81f280bfa185ba1df9c5ffee535631e4f1736f4 (patch)
treebaa956bdcb3a79af53e2d52b1820290398120b91
parent3a8727dc6bae5fd762256cbccdde55b75bed8769 (diff)
downloadzsh-a81f280bfa185ba1df9c5ffee535631e4f1736f4.tar.gz
zsh-a81f280bfa185ba1df9c5ffee535631e4f1736f4.tar.xz
zsh-a81f280bfa185ba1df9c5ffee535631e4f1736f4.zip
40010: builtins: Say 'bad option: +x', not 'bad option: -x', when +x was passed.
-rw-r--r--ChangeLog3
-rw-r--r--Src/builtin.c5
-rw-r--r--Test/A02alias.ztst5
3 files changed, 11 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 88727c93b..53dcc07de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2016-11-28  Daniel Shahaf  <d.s@daniel.shahaf.name>
 
+	* 40010: Src/builtin.c, Test/A02alias.ztst: builtins: Say
+	'bad option: +x', not 'bad option: -x', when +x was passed.
+
 	* 40009: Src/hashtable.c: alias -L: Emit aliases that begin
 	with a plus sign correctly.
 
diff --git a/Src/builtin.c b/Src/builtin.c
index ab159ad09..e641a97a1 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -249,7 +249,7 @@ int
 execbuiltin(LinkList args, LinkList assigns, Builtin bn)
 {
     char *pp, *name, *optstr;
-    int flags, sense, argc, execop, xtr = isset(XTRACE);
+    int flags, argc, execop, xtr = isset(XTRACE);
     struct options ops;
 
     /* initialise options structure */
@@ -294,6 +294,7 @@ execbuiltin(LinkList args, LinkList assigns, Builtin bn)
 	/* Sort out the options. */
 	if (optstr) {
 	    char *arg = *argv;
+	    int sense; /* 1 for -x, 0 for +x */
 	    /* while arguments look like options ... */
 	    while (arg &&
 		   /* Must begin with - or maybe + */
@@ -387,7 +388,7 @@ execbuiltin(LinkList args, LinkList assigns, Builtin bn)
 		if (*arg) {
 		    if(*arg == Meta)
 			*++arg ^= 32;
-		    zwarnnam(name, "bad option: -%c", *arg);
+		    zwarnnam(name, "bad option: %c%c", "+-"[sense], *arg);
 		    return 1;
 		}
 		arg = *++argv;
diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst
index 1e09cd3f1..e52578ec3 100644
--- a/Test/A02alias.ztst
+++ b/Test/A02alias.ztst
@@ -110,3 +110,8 @@
 127:No endless loop with suffix alias in command position
 >You said it.
 ?(eval):1: command not found: thingummy.mysuff
+
+  alias +x; alias -z
+1:error message has the correct sign
+?(eval):alias:1: bad option: +x
+?(eval):alias:1: bad option: -z