<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>∃xistential Type &#187; shell scripting</title>
	<atom:link href="http://existentialtype.net/tag/shell-scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://existentialtype.net</link>
	<description>For People Who Like Type and Types</description>
	<lastBuildDate>Sat, 12 May 2012 16:35:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Lazy environment variables</title>
		<link>http://existentialtype.net/2008/03/05/lazy-environment-variables/</link>
		<comments>http://existentialtype.net/2008/03/05/lazy-environment-variables/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 09:10:04 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
				<category><![CDATA[hacking]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[call-by-name]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[shell scripting]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://existentialtype.net/2008/03/05/lazy-environment-variables/</guid>
		<description><![CDATA[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 &#160; 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 [...]]]></description>
			<content:encoded><![CDATA[<p>I was just thinking that it would be really useful if command-line shells supported lazy environment variables.  Lately, because of my work on <a href="http://www.scala-lang.org/">Scala</a> I will often find myself entering a line something like</p>
<pre class="bash">&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH=</span><span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>linuxsoft<span style="color: #000000; font-weight: bold;">/</span>apps<span style="color: #000000; font-weight: bold;">/</span>java-ibm<span style="color: #000000;">-1.5</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PATH</span>
...</pre>
<p>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 <a href="http://zsh.org/">ZSH</a> shell scripts to make it a little less work.</p>
<p>Just having a short macro that does the above for all the various Java runtimes is not ideal, because then my <code lang="bash">PATH</code> 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 <code lang="bash">PATH</code> as a string.  However, the most elegant solution would simply be to not perform expansion on the contents of <code lang="bash">PATH</code> until it must be passed as part of an <code>exec</code></p>
<p>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</p>
<pre class="bash">&nbsp;
lazy <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH=</span><span style="color: #007800;">$JAVA_BIN</span>:<span style="color: #007800;">$PATH</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">JAVA_BIN=</span><span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>linuxsoft<span style="color: #000000; font-weight: bold;">/</span>apps<span style="color: #000000; font-weight: bold;">/</span>java-ibm<span style="color: #000000;">-1.5</span><span style="color: #000000; font-weight: bold;">/</span>bin
...</pre>
<p>And then my scripts can just operate on <code lang="bash">JAVA_BIN</code> rather than having to modify <code lang="bash">PATH</code> directly.</p>
<p><strong>Update</strong>: I just noticed that setting the variable <code lang="bash">JAVACMD</code> is enough for most purposes, but the above concept still seems reasonable.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/03/05/lazy-environment-variables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

