Implement `set +o', which displays the currently set options in a format
suitable for re-input into the shell.
This commit is contained in:
parent
ba545bbb61
commit
d513af6a66
@ -200,13 +200,28 @@ options(int cmdline)
|
||||
STATIC void
|
||||
minus_o(char *name, int val)
|
||||
{
|
||||
int i;
|
||||
int doneset, i;
|
||||
|
||||
if (name == NULL) {
|
||||
out1str("Current option settings\n");
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
out1fmt("%-16s%s\n", optlist[i].name,
|
||||
optlist[i].val ? "on" : "off");
|
||||
if (val) {
|
||||
/* "Pretty" output. */
|
||||
out1str("Current option settings\n");
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
out1fmt("%-16s%s\n", optlist[i].name,
|
||||
optlist[i].val ? "on" : "off");
|
||||
} else {
|
||||
/* Output suitable for re-input to shell. */
|
||||
for (doneset = i = 0; i < NOPTS; i++)
|
||||
if (optlist[i].val) {
|
||||
if (!doneset) {
|
||||
out1str("set");
|
||||
doneset = 1;
|
||||
}
|
||||
out1fmt(" -o %s", optlist[i].name);
|
||||
}
|
||||
if (doneset)
|
||||
out1c('\n');
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
if (equal(name, optlist[i].name)) {
|
||||
|
@ -301,6 +301,14 @@ command line editor:
|
||||
set -E
|
||||
set -o emacs
|
||||
.Ed
|
||||
.Pp
|
||||
If used without an argument, the
|
||||
.Fl o
|
||||
option displays the current option settings in a human-readable format.
|
||||
If
|
||||
.Cm +o
|
||||
is used without an argument, the current option settings are output
|
||||
in a format suitable for re-input into the shell.
|
||||
.Ss Lexical Structure
|
||||
The shell reads input in terms of lines from a file and breaks
|
||||
it up into words at whitespace (blanks and tabs), and at
|
||||
|
Loading…
x
Reference in New Issue
Block a user