zsh-workers
 help / color / mirror / code / Atom feed
From: Wayne Davison <wayne@clari.net>
To: zsh-workers@math.gatech.edu
Subject: Option Options
Date: Fri, 02 Aug 1996 15:23:26 -0700	[thread overview]
Message-ID: <199608022223.PAA20157@bebop.clari.net> (raw)

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


             reply	other threads:[~1996-08-02 22:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-02 22:23 Wayne Davison [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199608022223.PAA20157@bebop.clari.net \
    --to=wayne@clari.net \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).