mirror of
https://github.com/zsh-users/zsh
synced 2024-07-21 10:14:19 +00:00
18530: print option states with set -o' or
set +o'
This commit is contained in:
parent
4e309d2cdd
commit
09c5818b39
|
@ -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>
|
2003-05-15 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* 18539: Src/init.c: upgrade 18536 to autoload zle on
|
* 18539: Src/init.c: upgrade 18536 to autoload zle on
|
||||||
|
|
|
@ -973,7 +973,7 @@ cindex(parameters, positional)
|
||||||
cindex(parameters, setting array)
|
cindex(parameters, setting array)
|
||||||
cindex(array parameters, setting)
|
cindex(array parameters, setting)
|
||||||
pindex(KSH_ARRAYS, use of)
|
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
|
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
|
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
|
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
|
sort arguments in descending order. For the meaning of the other flags, see
|
||||||
ifzman(zmanref(zshoptions))\
|
ifzman(zmanref(zshoptions))\
|
||||||
ifnzman(noderef(Options))\
|
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
|
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
|
the given var(arg)s; if no var(name) is specified, all arrays are printed
|
||||||
|
|
|
@ -562,9 +562,9 @@ bin_set(char *nam, char **args, Options ops, int func)
|
||||||
if (!*++*args)
|
if (!*++*args)
|
||||||
args++;
|
args++;
|
||||||
if (!*args) {
|
if (!*args) {
|
||||||
zwarnnam(nam, "string expected after -o", NULL, 0);
|
printoptionstates(hadplus);
|
||||||
inittyptab();
|
inittyptab();
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
if(!(optno = optlookup(*args)))
|
if(!(optno = optlookup(*args)))
|
||||||
zwarnnam(nam, "no such option: %s", *args, 0);
|
zwarnnam(nam, "no such option: %s", *args, 0);
|
||||||
|
|
|
@ -710,6 +710,33 @@ dashgetfn(Param pm)
|
||||||
return buf;
|
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 */
|
/* Print option list for --help */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
Loading…
Reference in a new issue