I was just thinking that it would be really useful if command-line shells supported lazy environment variables. Lately, because of my work on Scala I will often find myself entering a line something like
- export PATH=/home/linuxsoft/apps/java-ibm-1.5/bin:$PATH
This is, despite the write-once promises of Jave (well, JVM bytecode), Scala will fail to build or a test will fail on specific implementations of the Java runtime and VM. I have been doing this so frequently, I finally decided to write some ZSH shell scripts to make it a little less work.
Just having a short macro that does the above for all the various Java runtimes is not ideal, because then my
keeps getting longer and longer. ZSH might be smart about this when caching lookups, but it is inelegant. Another solution is to write something that does a search and replace on my
as a string. However, the most elegant solution would simply be to not perform expansion on the contents of
until it must be passed as part of an
ZSH can do a lot, so maybe it already has some feature that approximates this, but it would be nice if I could just write something like
- lazy export PATH=$JAVA_BIN:$PATH
- export JAVA_BIN=/home/linuxsoft/apps/java-ibm-1.5/bin
And then my scripts can just operate on
rather than having to modify
Update: I just noticed that setting the variable
is enough for most purposes, but the above concept still seems reasonable.