1
0
mirror of https://github.com/zsh-users/zsh synced 2024-07-08 19:55:44 +00:00

18530: print option states with set -o' or set +o'

This commit is contained in:
Oliver Kiddle 2003-05-15 09:39:55 +00:00
parent 4e309d2cdd
commit 09c5818b39
4 changed files with 39 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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 */
/**/