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

Re: Tying multiple environment variables together



On Apr 11, 10:18am, Steve Talley wrote:
}
} Unfortunately when I change the value of one I have to change all
} three.  Is it possible to tie the values together, so that after
} changing one they all get changed?

Not directly (though this sounds like a good basis for a zmodload
module of some kind).  The easiest thing is to use precmd() to force
two of them to always match the third, e.g.

	precmd() {
	    export JDKHOME=$JAVA_HOME
	    export JDK_HOME=$JAVA_HOME
	}

Then always change JAVA_HOME when you want to change all of them.

I believe recent versions of ksh have a syntax for specifying set/unset
callbacks on parameters, so zsh will probably pick up that feature before
long.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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