diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Doc/Zsh/builtins.yo | 7 | ||||
-rw-r--r-- | Src/builtin.c | 4 | ||||
-rw-r--r-- | Src/options.c | 27 |
4 files changed, 39 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog index 5550e3a02..234c46937 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-05-15 Oliver Kiddle <opk@zsh.org> + + * 18530: Src/builtin.c, Src/options.c, Doc/Zsh/builtins.yo: + print option states with `set -o' or `set +o' + 2003-05-15 Peter Stephenson <pws@csr.com> * 18539: Src/init.c: upgrade 18536 to autoload zle on diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index bbac85e4e..a31e7fde6 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -973,7 +973,7 @@ cindex(parameters, positional) cindex(parameters, setting array) cindex(array parameters, setting) pindex(KSH_ARRAYS, use of) -item(tt(set) [ {tt(PLUS())|tt(-)}var(options) | {tt(PLUS())|tt(-)}tt(o) var(option_name) ] ... [ {tt(PLUS())|tt(-)}tt(A) [ var(name) ] ] [ var(arg) ... ])( +item(tt(set) [ {tt(PLUS())|tt(-)}var(options) | {tt(PLUS())|tt(-)}tt(o) [ var(option_name) ] ] ... [ {tt(PLUS())|tt(-)}tt(A) [ var(name) ] ] [ var(arg) ... ])( Set the options for the shell and/or set the positional parameters, or declare and set an array. If the tt(-s) option is given, it causes the specified arguments to be sorted before assigning them to the positional @@ -981,7 +981,10 @@ parameters (or to the array var(name) if tt(-A) is used). With tt(PLUS()s) sort arguments in descending order. For the meaning of the other flags, see ifzman(zmanref(zshoptions))\ ifnzman(noderef(Options))\ -. Flags may be specified by name using the tt(-o) option. +. Flags may be specified by name using the tt(-o) option. If no option +name is supplied with tt(-o), the current option states are printed. +With tt(PLUS()o) they are printed in a form that can be used as input +to the shell. If the tt(-A) flag is specified, var(name) is set to an array containing the given var(arg)s; if no var(name) is specified, all arrays are printed diff --git a/Src/builtin.c b/Src/builtin.c index 02f113a31..96ed1e61b 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -562,9 +562,9 @@ bin_set(char *nam, char **args, Options ops, int func) if (!*++*args) args++; if (!*args) { - zwarnnam(nam, "string expected after -o", NULL, 0); + printoptionstates(hadplus); inittyptab(); - return 1; + return 0; } if(!(optno = optlookup(*args))) zwarnnam(nam, "no such option: %s", *args, 0); diff --git a/Src/options.c b/Src/options.c index f206d0ab3..8cc8f2a8e 100644 --- a/Src/options.c +++ b/Src/options.c @@ -710,6 +710,33 @@ dashgetfn(Param pm) return buf; } +/* print options for set -o/+o */ + +/**/ +void +printoptionstates(int hadplus) +{ + scanhashtable(optiontab, 1, 0, OPT_ALIAS, printoptionnodestate, hadplus); +} + +/**/ +static void +printoptionnodestate(HashNode hn, int hadplus) +{ + Optname on = (Optname) hn; + int optno = on->optno; + + if (hadplus) { + if (defset(on) != isset(optno)) + printf("set -o %s%s\n", defset(on) ? "no" : "", on->nam); + } else { + if (defset(on)) + printf("no%-19s %s\n", on->nam, isset(optno) ? "off" : "on"); + else + printf("%-21s %s\n", on->nam, isset(optno) ? "on" : "off"); + } +} + /* Print option list for --help */ /**/ |