zsh-workers
 help / color / mirror / code / Atom feed
* Option Options
@ 1996-08-02 22:23 Wayne Davison
  1996-08-02 23:32 ` Zoltan Hidvegi
  1996-08-03 20:14 ` Zefram
  0 siblings, 2 replies; 5+ messages in thread
From: Wayne Davison @ 1996-08-02 22:23 UTC (permalink / raw)
  To: zsh-workers

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---


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1996-08-03 21:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-02 22:23 Option Options Wayne Davison
1996-08-02 23:32 ` Zoltan Hidvegi
1996-08-03 20:14 ` Zefram
1996-08-03 20:38   ` Wayne Davison
1996-08-03 20:52     ` Zefram

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).