From 45548c80dfecacc27ec58acc52a4c590d87eda77 Mon Sep 17 00:00:00 2001 From: stefanf Date: Sat, 29 Oct 2005 18:41:35 +0000 Subject: 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 --- bin/sh/options.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'bin') 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++) -- cgit v1.1