diff options
author | tjr <tjr@FreeBSD.org> | 2002-05-25 12:11:58 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-05-25 12:11:58 +0000 |
commit | 290ce9e46606d008f6d60d1fe24ff8a8d4f71032 (patch) | |
tree | ccb1108e566e14015f8083fb1aef065262fb1ec3 /bin | |
parent | 8f932f078dbf7a2b74e03bcdf653e190324f1174 (diff) | |
download | FreeBSD-src-290ce9e46606d008f6d60d1fe24ff8a8d4f71032.zip FreeBSD-src-290ce9e46606d008f6d60d1fe24ff8a8d4f71032.tar.gz |
Implement `set +o', which displays the currently set options in a format
suitable for re-input into the shell.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/options.c | 25 | ||||
-rw-r--r-- | bin/sh/sh.1 | 8 |
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 |