Chris Morris wrote:
> Apparently, Win95 does not support file associations from the command line.

Not through the command line directly, no.  But indirectly, yes.

> [test case that executes IO#popen on a .rb file's path]
>
> ... even though .rb files are associated to ruby.exe. I can execute a .rb
> file from Explorer (double-click) or from the Start|Run... dialog. But from
> the command line (DOS box), it shrugs its shoulders.
> 
> First question, does anyone know a way to get this to work in 95? I assume
> it's Just The Way It Is.

The facility for using these associations in the Win95 command line is
provided by a program called start.exe in Windows' Command directory.
Executing the string 'start ' + @foo should do the same thing as typing the
contents of @foo in the Start|Run dialog (start.exe also has switches to
control how the program is launched).

I suppose an argument could be made that IO#popen should perhaps attempt to
run the command with start.exe on Windows if normal execution doesn't work.

> Second question, what's a good workaround? One thought I'd had was to add
> code to check for a shebang #! at the top of the file and explicitly execute
> that in the popen call.

When I change the line:
    f = IO.popen(@testfilename)
to
    f = IO.popen('start ' + @testfilename)
it works fine on my installation of mingw32 Ruby 1.6.2.

However, on the cygwin version of Ruby 1.6.1 I have, the file's path is
"/cygdrive/c/WINDOWS/TEMP/testfile.rb", which start.exe (being a Windows
program of average intelligence) is unable to do anything sensible with.
I'm not sure how to work around that.  Hope this helps, and good luck.

---
Zach Baker <zach / zachbaker.com>
"start start start start start start start"