summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2005-10-29 18:41:35 +0000
committerstefanf <stefanf@FreeBSD.org>2005-10-29 18:41:35 +0000
commit45548c80dfecacc27ec58acc52a4c590d87eda77 (patch)
treec101c5f4669babc8c6912c9864dc105c9f0d13b1
parent26610cfe9b5e6587a4d8e59c1dfd4b12bd5d2bb7 (diff)
downloadFreeBSD-src-45548c80dfecacc27ec58acc52a4c590d87eda77.zip
FreeBSD-src-45548c80dfecacc27ec58acc52a4c590d87eda77.tar.gz
Include disabled options in the output of 'set +o'. POSIX says the output of
set +o can be used to reload previous settings, for this to work disabled options must be printed as well or otherwise options that were set in the mean time won't be turned off. To avoid an excessively long output line I formatted the output to print only six options per line. Submitted by: Jilles Tjoelker PR: 73500
-rw-r--r--bin/sh/options.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/bin/sh/options.c b/bin/sh/options.c
index d2c4a98..64e129e 100644
--- a/bin/sh/options.c
+++ b/bin/sh/options.c
@@ -247,7 +247,7 @@ end_options2:
STATIC void
minus_o(char *name, int val)
{
- int doneset, i;
+ int i;
if (name == NULL) {
if (val) {
@@ -258,16 +258,13 @@ minus_o(char *name, int val)
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');
+ for (i = 0; i < NOPTS; i++) {
+ if (i % 6 == 0)
+ out1str(i == 0 ? "set" : "\nset");
+ out1fmt(" %co %s", optlist[i].val ? '-' : '+',
+ optlist[i].name);
+ }
+ out1c('\n');
}
} else {
for (i = 0; i < NOPTS; i++)
OpenPOWER on IntegriCloud