Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: User installation script for new completion



"Bart Schaefer" wrote:
> } 	typeset -A options
> } 	options=($(setopt kshoptionprint;setopt))
> } 	[[ -o kshoptionprint ]] || options[kshoptionprint]=off
> } 	[[ -o monitor ]] && options[monitor]=on
> } 	[[ -o zle ]] && options[zle]=on
> 
> 	unsetopt ${(k)options[(R)off]} no${(k)^options[(R)on]}

Unfortunately that doesn't work because of the way options on by default
are printed with `no' in front anyway, in which case sticking another no in
front messes it up.  (Maybe your setopt is a function to get round it.)

However,

  unsetopt ${(k)options[(R)off]}
  setopt ${(k)options[(R)on]}

ought to do the trick.  But it doesn't; you get things like

  unsetopt: can't change option: singlecommand

which is misleading anyway.  Why don't we change it so that it doesn't
complain if you're setting an option to its existing value?

--- Src/options.c.so	Thu Mar 25 10:38:43 1999
+++ Src/options.c	Mon May  3 10:07:14 1999
@@ -635,6 +635,8 @@
 	}
     } else if(!force && (optno == INTERACTIVE || optno == SHINSTDIN ||
 	    optno == SINGLECOMMAND)) {
+	if (opts[optno] == value)
+	    return 0;
 	/* it is not permitted to change the value of these options */
 	return -1;
     } else if(!force && optno == USEZLE && value) {

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author