Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Function code breaking out of if then ...fi



Another inconsistency with error handling...

% fn() { setopt mumbly; print Got here; }
% fn
fn:setopt: no such option: mumbly
Got here
% fn() { set -o mumbly; print Got here; }
% fn
fn:set: no such option: mumbly

This is because set is a POSIX special builtin but setopt isn't.  It
should be documented, however.

Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.145
diff -p -u -r1.145 builtins.yo
--- Doc/Zsh/builtins.yo	11 Oct 2012 20:14:03 -0000	1.145
+++ Doc/Zsh/builtins.yo	5 Nov 2012 16:06:10 -0000
@@ -1361,6 +1361,11 @@ or without the tt(no) prefix remains the
 If the tt(-m) flag is given the arguments are taken as patterns
 (which should be quoted to protect them from filename expansion), and all
 options with names matching these patterns are set.
+
+Note that a bad option name does not cause execution of shell code
+to be aborted; this is different from `tt(set -o)'.  This is because
+tt(set) is regarded as a special builtin by the POSIX standard,
+but tt(setopt) is not.
 )
 findex(shift)
 cindex(parameters, positional)

pws



Messages sorted by: Reverse Date, Date, Thread, Author