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

* Re: Option Options
  1996-08-02 22:23 Option Options Wayne Davison
@ 1996-08-02 23:32 ` Zoltan Hidvegi
  1996-08-03 20:14 ` Zefram
  1 sibling, 0 replies; 5+ messages in thread
From: Zoltan Hidvegi @ 1996-08-02 23:32 UTC (permalink / raw)
  To: Wayne Davison; +Cc: zsh-workers

> 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

I like this idea.

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

That's fine because they have no real default value.

Zoltan


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

* Re: Option Options
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Zefram @ 1996-08-03 20:14 UTC (permalink / raw)
  To: Wayne Davison; +Cc: 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.

I'm not actually working on it at the moment.  I decided to wait until
after the 3.0 release before making functional changes like this.  But
if the consensus is in favour, it's really quite easy to produce a
patch.

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

That's going to break things.  Sometimes one *wants* a list of all
options -- not least in the completion for {un,}setopt.  If this change
is to be made, other things will have to change too.  This definitely
should wait.

Not that I'm implacably opposed to the idea -- I just think that such a
radical change to the behaviour of existing builtins in the default
case is a bad move right before a production release.

-zefram


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

* Re: Option Options
  1996-08-03 20:14 ` Zefram
@ 1996-08-03 20:38   ` Wayne Davison
  1996-08-03 20:52     ` Zefram
  0 siblings, 1 reply; 5+ messages in thread
From: Wayne Davison @ 1996-08-03 20:38 UTC (permalink / raw)
  To: Zefram; +Cc: zsh-workers

Zefram writes:
> That's going to break things.  Sometimes one *wants* a list of all
> options -- not least in the completion for {un,}setopt.

All the options are still there.  It's just that some of them are listed
by their "no" name as an option to turn off rather than an "option" that
is already turned on.  This makes the output more compatible with prior
zsh releases, so I don't see what the problem is.  Perhaps I am missing
something.

..wayne..


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

* Re: Option Options
  1996-08-03 20:38   ` Wayne Davison
@ 1996-08-03 20:52     ` Zefram
  0 siblings, 0 replies; 5+ messages in thread
From: Zefram @ 1996-08-03 20:52 UTC (permalink / raw)
  To: Wayne Davison; +Cc: A.Main, zsh-workers

>All the options are still there.  It's just that some of them are listed
>by their "no" name as an option to turn off rather than an "option" that
>is already turned on.  This makes the output more compatible with prior
>zsh releases, so I don't see what the problem is.  Perhaps I am missing
>something.

Oh, I see.  You list options that default on under their NO_ name.  I
suppose that's sensible.  It doesn't fundamentally change the behaviour
-- at least, no more than my option patch did.

The setopt completion example does need to be reverted to its previous
form though.

-zefram


^ 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).