summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c4
-rw-r--r--Src/options.c27
2 files changed, 29 insertions, 2 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 02f113a31..96ed1e61b 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -562,9 +562,9 @@ bin_set(char *nam, char **args, Options ops, int func)
if (!*++*args)
args++;
if (!*args) {
- zwarnnam(nam, "string expected after -o", NULL, 0);
+ printoptionstates(hadplus);
inittyptab();
- return 1;
+ return 0;
}
if(!(optno = optlookup(*args)))
zwarnnam(nam, "no such option: %s", *args, 0);
diff --git a/Src/options.c b/Src/options.c
index f206d0ab3..8cc8f2a8e 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -710,6 +710,33 @@ dashgetfn(Param pm)
return buf;
}
+/* print options for set -o/+o */
+
+/**/
+void
+printoptionstates(int hadplus)
+{
+ scanhashtable(optiontab, 1, 0, OPT_ALIAS, printoptionnodestate, hadplus);
+}
+
+/**/
+static void
+printoptionnodestate(HashNode hn, int hadplus)
+{
+ Optname on = (Optname) hn;
+ int optno = on->optno;
+
+ if (hadplus) {
+ if (defset(on) != isset(optno))
+ printf("set -o %s%s\n", defset(on) ? "no" : "", on->nam);
+ } else {
+ if (defset(on))
+ printf("no%-19s %s\n", on->nam, isset(optno) ? "off" : "on");
+ else
+ printf("%-21s %s\n", on->nam, isset(optno) ? "on" : "off");
+ }
+}
+
/* Print option list for --help */
/**/