Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "set -o foo" does not fail / does not abort the shell
- X-seq: zsh-workers 24210
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: "set -o foo" does not fail / does not abort the shell
- Date: Tue, 11 Dec 2007 13:56:50 +0000
- In-reply-to: <20071211125419.GS13079@xxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20071211125419.GS13079@xxxxxxxxxxxxxxxxxxx>
Vincent Lefevre wrote:
> I've tried the following with zsh-4.3.4-dev-4:
> 
> $ Src/zsh -f -c 'emulate sh; set -o foo; echo "Didn''t abort ($?)"'
> set: no such option: foo
> Didn't abort (0)
> 
> This is incorrect. The shell should abort as 'set' is a special
> builtin[*]:
This is easy.
> Please check the other special builtins:
> 
>   http://www.opengroup.org/onlinepubs/009695399/idx/sbi.html
This is a big job.  Someone will have to volunteer for this.
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.181
diff -u -r1.181 builtin.c
--- Src/builtin.c	6 Nov 2007 11:04:35 -0000	1.181
+++ Src/builtin.c	11 Dec 2007 13:08:10 -0000
@@ -567,9 +567,9 @@
 		    return 0;
 		}
 		if(!(optno = optlookup(*args)))
-		    zwarnnam(nam, "no such option: %s", *args);
+		    zerrnam(nam, "no such option: %s", *args);
 		else if(dosetopt(optno, action, 0))
-		    zwarnnam(nam, "can't change option: %s", *args);
+		    zerrnam(nam, "can't change option: %s", *args);
 		break;
 	    } else if(**args == 'A') {
 		if(!*++*args)
@@ -588,13 +588,15 @@
 		sort = action ? 1 : -1;
 	    else {
 	    	if (!(optno = optlookupc(**args)))
-		    zwarnnam(nam, "bad option: -%c", **args);
+		    zerrnam(nam, "bad option: -%c", **args);
 		else if(dosetopt(optno, action, 0))
-		    zwarnnam(nam, "can't change option: -%c", **args);
+		    zerrnam(nam, "can't change option: -%c", **args);
 	    }
 	}
 	args++;
     }
+    if (errflag)
+	return 1;
  doneoptions:
     inittyptab();
 
-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author