From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id IAA01921 for ; Sat, 3 Aug 1996 08:30:13 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id SAA29501; Fri, 2 Aug 1996 18:25:11 -0400 (EDT) Resent-Date: Fri, 2 Aug 1996 18:25:11 -0400 (EDT) Message-Id: <199608022223.PAA20157@bebop.clari.net> To: zsh-workers@math.gatech.edu Subject: Option Options Date: Fri, 02 Aug 1996 15:23:26 -0700 From: Wayne Davison Resent-Message-ID: <"lqJao1.0.tC7.61e0o"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1907 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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---