<?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: GUAS: Giving Unwanted Advice Series #1</title>
	<atom:link href="http://blog.mmediasys.com/2008/10/21/guas-is-giving-unwanted-advice-series-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mmediasys.com/2008/10/21/guas-is-giving-unwanted-advice-series-1/</link>
	<description>Compartiendo fragmentos de código con el mundo.</description>
	<lastBuildDate>Thu, 22 Jul 2010 22:33:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Charles L</title>
		<link>http://blog.mmediasys.com/2008/10/21/guas-is-giving-unwanted-advice-series-1/comment-page-1/#comment-252</link>
		<dc:creator>Charles L</dc:creator>
		<pubDate>Thu, 23 Oct 2008 02:22:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mmediasys.com/?p=85#comment-252</guid>
		<description>True - I used to use just =~ /win/, but that broke on darwin :), so I&#039;m currently using File::ALT_SEPARATOR, which is pretty lame too.</description>
		<content:encoded><![CDATA[<p>True &#8211; I used to use just =~ /win/, but that broke on darwin <img src='http://blog.mmediasys.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , so I&#8217;m currently using File::ALT_SEPARATOR, which is pretty lame too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luis</title>
		<link>http://blog.mmediasys.com/2008/10/21/guas-is-giving-unwanted-advice-series-1/comment-page-1/#comment-251</link>
		<dc:creator>Luis</dc:creator>
		<pubDate>Thu, 23 Oct 2008 00:01:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mmediasys.com/?p=85#comment-251</guid>
		<description>Funny fact: your regex for RUBY_PLATFORM will be part of my next article: never use win32, there is mingw also and a 64 bits version of Ruby on Windows (mswin64).

Funny, no? ;)</description>
		<content:encoded><![CDATA[<p>Funny fact: your regex for <span class="caps">RUBY</span>_PLATFORM will be part of my next article: never use win32, there is mingw also and a 64 bits version of Ruby on Windows (mswin64).</p>
<p>Funny, no? <img src='http://blog.mmediasys.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luis</title>
		<link>http://blog.mmediasys.com/2008/10/21/guas-is-giving-unwanted-advice-series-1/comment-page-1/#comment-250</link>
		<dc:creator>Luis</dc:creator>
		<pubDate>Wed, 22 Oct 2008 23:59:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mmediasys.com/?p=85#comment-250</guid>
		<description>Thank you Charles for your comment.

Indeed is tricky to be cross platform friendly and I believe the work from Daniel Berger (win32utils) and some other stuff should have been part of standard ruby distribution long time ago, replacing the POSIX only version they have.

The example I provided will work, but the problem is that for files like &#039;gem&#039; and &#039;gem.bat&#039; will find the first one and call it without extension.

On 1.8.6-p114 this wouldn&#039;t work, on newest versions works without issues.

Other problem is that @File.executable?@ think everything can be executed on Windows... such a lame support :P</description>
		<content:encoded><![CDATA[<p>Thank you Charles for your comment.</p>
<p>Indeed is tricky to be cross platform friendly and I believe the work from Daniel Berger (win32utils) and some other stuff should have been part of standard ruby distribution long time ago, replacing the <span class="caps">POSIX </span>only version they have.</p>
<p>The example I provided will work, but the problem is that for files like &#8216;gem&#8217; and &#8216;gem.bat&#8217; will find the first one and call it without extension.</p>
<p>On 1.8.6-p114 this wouldn&#8217;t work, on newest versions works without issues.</p>
<p>Other problem is that <code>File.executable?</code> think everything can be executed on Windows&#8230; such a lame support <img src='http://blog.mmediasys.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles L</title>
		<link>http://blog.mmediasys.com/2008/10/21/guas-is-giving-unwanted-advice-series-1/comment-page-1/#comment-249</link>
		<dc:creator>Charles L</dc:creator>
		<pubDate>Wed, 22 Oct 2008 23:37:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mmediasys.com/?p=85#comment-249</guid>
		<description>I agree that trying to keep ruby code platform neutral is a good idea. Theres more we can do to facilitate this I think - the fire brigade is a good idea for example (http://firebrigade.seattlerb.org/), in the same vein as CPAN or CRAN&#039;s automated testing, yet unfortunately it seems to no longer be in operation. 

Other examples would be using some of Daniel Berger&#039;s excellent platform abstraction libraries (eg sys-*), and maybe integrating stuff like win32-process et al so that Process is more platform neutral.

I think your example highlights the difficultly of writing portable code (which is probably why many of us often don&#039;t bother). I think the example won&#039;t work on windows due to executable extensions. Maybe something like this:


def where(app)
  pathext = (ENV[&#039;PATHEXT&#039;] &#124;&#124; &#039;.COM;.EXE;.BAT;.CMD&#039;).split(&#039;;&#039;) if RUBY_PLATFORM =~ /win32/
  ENV[&#039;PATH&#039;].split(File::PATH_SEPARATOR).each do &#124;path&#124;
    fn = File.join(path, app)
    if pathext
      pathext.each { &#124;ext&#124; return fn + ext if File.exist?(fn + ext) and File.executable?(fn + ext) }
    else
      return fn if File.exist?(fn) and File.executable?(fn)
    end
  end
  nil
end</description>
		<content:encoded><![CDATA[<p>I agree that trying to keep ruby code platform neutral is a good idea. Theres more we can do to facilitate this I think &#8211; the fire brigade is a good idea for example (<a href="http://firebrigade.seattlerb.org/" rel="nofollow">http://firebrigade.seattlerb.org/</a>), in the same vein as <span class="caps">CPAN </span>or <span class="caps">CRAN&#8217;</span>s automated testing, yet unfortunately it seems to no longer be in operation. </p>
<p>Other examples would be using some of Daniel Berger&#8217;s excellent platform abstraction libraries (eg sys-*), and maybe integrating stuff like win32-process et al so that Process is more platform neutral.</p>
<p>I think your example highlights the difficultly of writing portable code (which is probably why many of us often don&#8217;t bother). I think the example won&#8217;t work on windows due to executable extensions. Maybe something like this:</p>
<p>def where(app)<br />
  pathext = (ENV['PATHEXT'] || &#8216;.COM;.EXE;.BAT;.CMD&#8217;).split(&#8216;;&#8217;) if <span class="caps">RUBY</span>_PLATFORM =~ /win32/<br />
  <span class="caps">ENV</span>['PATH'].split(File::PATH_SEPARATOR).each do |path|<br />
    fn = File.join(path, app)<br />
    if pathext<br />
      pathext.each { |ext| return fn + ext if File.exist?(fn + ext) and File.executable?(fn + ext) }<br />
    else<br />
      return fn if File.exist?(fn) and File.executable?(fn)<br />
    end<br />
  end<br />
  nil<br />
end</p>
]]></content:encoded>
	</item>
</channel>
</rss>
