summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/sh/options.c25
-rw-r--r--bin/sh/sh.18
2 files changed, 28 insertions, 5 deletions
diff --git a/bin/sh/options.c b/bin/sh/options.c
index dbcb67e..07ca3db 100644
--- a/bin/sh/options.c
+++ b/bin/sh/options.c
@@ -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)) {
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index 8518687..a5c61e8 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -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
OpenPOWER on IntegriCloud