Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Option Options
- X-seq: zsh-workers 1907
- From: Wayne Davison <wayne@xxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: Option Options
- Date: Fri, 02 Aug 1996 15:23:26 -0700
One thing I think that would be nice to get put into the 3.0 release is
the option naming cleanup that Zefram (I believe) is working on. Even
if it means delaying the release a little, I like the idea of having
better-named options and some aliases for backward compatibility.
I also like the idea that Bart has espoused of having little or no options
show up in setopt's output if the shell is running in a default manner.
The following patch will undoubtedly be controversial, but it changes the
(un)setopt commands to take into account if this option is on by default
in the current emulation mode. Here's the output I get running it with
"zsh -f":
% setopt
interactive
monitor
norcs
shinstdin
zle
Note that all the "special" options show up. This could be changed if
someone wished to mark them as OPT_SPECIAL|OPT_ALL (or whatever).
This does cause all non-default options to be referred to by their
"no" name (like nonomatch).
Finally, I corrected a comment in globals.h that referred to OPT_SET,
which doesn't seem to exist.
..wayne..
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: builtin.c
@@ -433,13 +433,22 @@
/* ksh-style option display -- list all options, *
* with an indication of current status */
printf("Current option settings\n");
- for(optno = 1; optno < OPT_SIZE; optno++)
- printf("%-20s%s\n", optns[optno].name, isset(optno) ? "on" : "off");
- } else
+ for(optno = 1; optno < OPT_SIZE; optno++) {
+ if (defset(optno))
+ printf("no%-20s%s\n", optns[optno].name, isset(optno) ? "off" : "on");
+ else
+ printf("%-22s%s\n", optns[optno].name, isset(optno) ? "on" : "off");
+ }
+ } else {
/* list all options that are on, or all that are off */
- for(optno = 1; optno < OPT_SIZE; optno++)
- if (set == isset(optno))
+ for(optno = 1; optno < OPT_SIZE; optno++) {
+ if (set == (isset(optno) ^ defset(optno))) {
+ if (set ^ isset(optno))
+ fputs("no", stdout);
puts(optns[optno].name);
+ }
+ }
+ }
}
/**** job control builtins ****/
Index: globals.h
@@ -451,7 +451,7 @@
EXTERN int emulation;
-/* the options; e.g. if opts[SHGLOB] == OPT_SET, SH_GLOB is turned on */
+/* the options; e.g. if opts[SHGLOB] != 0, SH_GLOB is turned on */
EXTERN char opts[OPT_SIZE];
Index: init.c
@@ -173,7 +173,7 @@
for(optno = OPT_SIZE; --optno; )
if((fully && !(optns[optno].flags & OPT_SPECIAL)) ||
(optns[optno].flags & OPT_EMULATE))
- opts[optno] = !!(optns[optno].flags & (1 << emulation));
+ opts[optno] = defset(optno);
}
static char *cmd;
Index: zsh.h
@@ -1159,6 +1159,7 @@
#undef isset
#define isset(X) (opts[X])
#define unset(X) (!opts[X])
+#define defset(X) (!!(optns[X].flags & (1 << emulation)))
#define interact (isset(INTERACTIVE))
#define jobbing (isset(MONITOR))
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Messages sorted by:
Reverse Date,
Date,
Thread,
Author