<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Pathmunge</title>
	<atom:link href="http://involution.com/2006/05/11/pathmunge/feed/" rel="self" type="application/rss+xml" />
	<link>http://involution.com/2006/05/11/pathmunge/</link>
	<description>Tony Perrie&#039;s Weblog</description>
	<lastBuildDate>Tue, 15 May 2012 22:43:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Tim Bingham</title>
		<link>http://involution.com/2006/05/11/pathmunge/comment-page-1/#comment-4165</link>
		<dc:creator>Tim Bingham</dc:creator>
		<pubDate>Fri, 01 Dec 2006 17:20:40 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/2006/05/11/pathmunge/#comment-4165</guid>
		<description>The pathmunge() above dosen&#039;t work - it always adds its first argument to PATH, even if it is already present.

The problem is in the argument to egrep which is quoted with single quotes so the $1 doesn&#039;t get expanded. This means that egrep doesn&#039;t search PATH for the first argument, instead it searches literally for &#039;$1&#039;.

The fix is to use  double quotes  like this &quot;(^&#124;:)$1($&#124;:)&quot;  instead of &#039;(^&#124;:)$1($&#124;:)&#039; 

Normally I wouldn&#039;t be such a pedant but this page is the top hit when googling for &quot;pathmunge&quot; :-)</description>
		<content:encoded><![CDATA[<p>The pathmunge() above dosen&#8217;t work &#8211; it always adds its first argument to PATH, even if it is already present.</p>
<p>The problem is in the argument to egrep which is quoted with single quotes so the $1 doesn&#8217;t get expanded. This means that egrep doesn&#8217;t search PATH for the first argument, instead it searches literally for &#8216;$1&#8242;.</p>
<p>The fix is to use  double quotes  like this &#8220;(^|:)$1($|:)&#8221;  instead of &#8216;(^|:)$1($|:)&#8217; </p>
<p>Normally I wouldn&#8217;t be such a pedant but this page is the top hit when googling for &#8220;pathmunge&#8221; :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JTAxx</title>
		<link>http://involution.com/2006/05/11/pathmunge/comment-page-1/#comment-265</link>
		<dc:creator>JTAxx</dc:creator>
		<pubDate>Fri, 12 May 2006 18:43:49 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/2006/05/11/pathmunge/#comment-265</guid>
		<description>NO!</description>
		<content:encoded><![CDATA[<p>NO!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Administrator</title>
		<link>http://involution.com/2006/05/11/pathmunge/comment-page-1/#comment-264</link>
		<dc:creator>Administrator</dc:creator>
		<pubDate>Fri, 12 May 2006 18:27:31 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/2006/05/11/pathmunge/#comment-264</guid>
		<description>That&#039;s a pipe, man.  Come on, get with the program...</description>
		<content:encoded><![CDATA[<p>That&#8217;s a pipe, man.  Come on, get with the program&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JTAxx</title>
		<link>http://involution.com/2006/05/11/pathmunge/comment-page-1/#comment-263</link>
		<dc:creator>JTAxx</dc:creator>
		<pubDate>Fri, 12 May 2006 18:17:10 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/2006/05/11/pathmunge/#comment-263</guid>
		<description>my question 2 was in regards to the first &quot;&#124;&quot;, but now i see that you pipe the echo to the egrep then the ! refers to the final output...life&#039;s hard without parenthese!</description>
		<content:encoded><![CDATA[<p>my question 2 was in regards to the first &#8220;|&#8221;, but now i see that you pipe the echo to the egrep then the ! refers to the final output&#8230;life&#8217;s hard without parenthese!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Administrator</title>
		<link>http://involution.com/2006/05/11/pathmunge/comment-page-1/#comment-262</link>
		<dc:creator>Administrator</dc:creator>
		<pubDate>Fri, 12 May 2006 16:53:16 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/2006/05/11/pathmunge/#comment-262</guid>
		<description>All that pathmunge does is sets up a bash function to add directories to the beginning or at the end of your &lt;code&gt;$PATH&lt;/code&gt;
&lt;p&gt;&lt;b&gt;Before&lt;/b&gt;: &lt;code&gt;pathmunge ~/bin&lt;/code&gt; would set &lt;code&gt;PATH=~/bin:$PATH&lt;/code&gt;
&lt;b&gt;After&lt;/b&gt;: &lt;code&gt;pathmunge ~/bin after&lt;/code&gt; would set &lt;code&gt;PATH=$PATH:~/bin&lt;/code&gt;&lt;/p&gt;

The egrep nonsense at the beginning is to make sure that the path doesn&#039;t already exist in your path (prevents you from adding it twice, aliases notwithstanding).  The parentheses and &#124; character in a regular expression is indeed a logical OR operation.  E.g. (Jer&#124;Ch)rome would match Jerome and Chrome.  These operations fall into the realm of extended regular expressions which is why the author rightly called egrep.  The $ and ^ in a regex means beginning of line and end of line.  So, the egrep stuff is just a low rent way of parsing a colon delimited $PATH.  If you add this function to your ~/.bashrc or /etc/bashrc, bash treats it as a command that can be invoked from the command-line.</description>
		<content:encoded><![CDATA[<p>All that pathmunge does is sets up a bash function to add directories to the beginning or at the end of your <code>$PATH</code></p>
<p><b>Before</b>: <code>pathmunge ~/bin</code> would set <code>PATH=~/bin:$PATH</code><br />
<b>After</b>: <code>pathmunge ~/bin after</code> would set <code>PATH=$PATH:~/bin</code></p>
<p>The egrep nonsense at the beginning is to make sure that the path doesn&#8217;t already exist in your path (prevents you from adding it twice, aliases notwithstanding).  The parentheses and | character in a regular expression is indeed a logical OR operation.  E.g. (Jer|Ch)rome would match Jerome and Chrome.  These operations fall into the realm of extended regular expressions which is why the author rightly called egrep.  The $ and ^ in a regex means beginning of line and end of line.  So, the egrep stuff is just a low rent way of parsing a colon delimited $PATH.  If you add this function to your ~/.bashrc or /etc/bashrc, bash treats it as a command that can be invoked from the command-line.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ali</title>
		<link>http://involution.com/2006/05/11/pathmunge/comment-page-1/#comment-259</link>
		<dc:creator>Ali</dc:creator>
		<pubDate>Fri, 12 May 2006 16:16:10 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/2006/05/11/pathmunge/#comment-259</guid>
		<description>Yeah, I have no idea what you&#039;re talking about.</description>
		<content:encoded><![CDATA[<p>Yeah, I have no idea what you&#8217;re talking about.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JTAxx</title>
		<link>http://involution.com/2006/05/11/pathmunge/comment-page-1/#comment-258</link>
		<dc:creator>JTAxx</dc:creator>
		<pubDate>Fri, 12 May 2006 15:22:01 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/2006/05/11/pathmunge/#comment-258</guid>
		<description>1. what does ! echo $PATH do?
2. does &quot;&#124;&quot; == &quot;OR&quot;
3. i can&#039;t tell how this updates your profile.</description>
		<content:encoded><![CDATA[<p>1. what does ! echo $PATH do?<br />
2. does &#8220;|&#8221; == &#8220;OR&#8221;<br />
3. i can&#8217;t tell how this updates your profile.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

