[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How do I tell when I'm on Cygwin?

James Gray

10/24/2006 5:43:00 PM

HighLine has some code like this:

begin
require "Win32API"

if # I'm looking for the line that goes right here (see below).
raise LoadError, "On Cygwin, not pure Windows."
end

# assume we're on Windows here...
rescue LoadError
# assume we're on a Posix OS here...
end

The problem is that Cygwin is using the Windows code and the Posix
code would be a better choice there. What's a test I can use to
detect Cygwin in this scenario?

James Edward Gray II

57 Answers

Ara.T.Howard

10/24/2006 5:52:00 PM

0

Wilson Bilkovich

10/24/2006 6:15:00 PM

0

On 10/24/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
> On Wed, 25 Oct 2006, James Edward Gray II wrote:
>
> > HighLine has some code like this:
> >
> > begin
> > require "Win32API"
> >
> > if # I'm looking for the line that goes right here (see below).
> > raise LoadError, "On Cygwin, not pure Windows."
> > end
> >
> > # assume we're on Windows here...
> > rescue LoadError
> > # assume we're on a Posix OS here...
> > end
> >
> > The problem is that Cygwin is using the Windows code and the Posix code would
> > be a better choice there. What's a test I can use to detect Cygwin in this
> > scenario?
> >
> > James Edward Gray II
>
> posix = Process.fork{} and Process.wait rescue nil
>

Everyone, please remember that Ara is kidding about this. Please do
not let this become an idiom.
The fact that the Win32 version of Ruby doesn't support fork is a
temporary and unfortunate implementation detail, not something you can
rely on.

Ara.T.Howard

10/24/2006 6:29:00 PM

0

Gregory Brown

10/24/2006 6:41:00 PM

0

On 10/24/06, Nick Sieger <nicksieger@gmail.com> wrote:

> I /think/ RUBY_PLATFORM is different for cygwin than the pure windows
> version, but I don't have a cygwin install nearby to confirm. Perhaps

Via One click installer in regular windows:

irb(main):001:0> RUBY_PLATFORM
=> "i386-mswin32"

On CYGWIN:

irb(main):001:0> RUBY_PLATFORM
=> "i386-cygwin"

M. Edward (Ed) Borasky

10/24/2006 9:16:00 PM

0

ara.t.howard@noaa.gov wrote:
> On Wed, 25 Oct 2006, Wilson Bilkovich wrote:
>
>> Everyone, please remember that Ara is kidding about this. Please do
>> not let
>> this become an idiom. The fact that the Win32 version of Ruby doesn't
>> support fork is a temporary and unfortunate implementation detail, not
>> something you can rely on.
>
> you are spoiling all the fun!
>
> ;-)
>
> -a

It's easier even than that ... just look up. If Austin Ziegler is
sneering at you, you're on CygWin.

<ducking>

Gregory Brown

10/24/2006 9:45:00 PM

0

On 10/24/06, M. Edward (Ed) Borasky <znmeb@cesmail.net> wrote:

> It's easier even than that ... just look up. If Austin Ziegler is
> sneering at you, you're on CygWin.

But that's not true. You can get an identical scenario if you browse to:
shootout.alioth.debian.org :)

James Gray

10/25/2006 12:33:00 AM

0

On Oct 24, 2006, at 1:40 PM, Gregory Brown wrote:

> irb(main):001:0> RUBY_PLATFORM
> => "i386-cygwin"

It seems safer to target this one as an exception, rather than mswin,
so I'll go with that.

One last question though, if Termios was installed for Cygwin would
it work OK there? I'm trying to figure out if I need to bypass
HighLine's search for that too.

Thanks for the help all.

James Edward Gray II


Gregory Brown

10/25/2006 12:40:00 AM

0

On 10/24/06, James Edward Gray II <james@grayproductions.net> wrote:
> On Oct 24, 2006, at 1:40 PM, Gregory Brown wrote:
>
> > irb(main):001:0> RUBY_PLATFORM
> > => "i386-cygwin"
>
> It seems safer to target this one as an exception, rather than mswin,
> so I'll go with that.
>
> One last question though, if Termios was installed for Cygwin would
> it work OK there? I'm trying to figure out if I need to bypass
> HighLine's search for that too.

I have no idea how to install termios for Cygwin since it's not part
of the standard distribution (i don't think), and I'm not really a
Cygwin user.

However, stty is included with Cygwin, so I think highline would work
using that.

M. Edward (Ed) Borasky

10/25/2006 1:00:00 AM

0

Gregory Brown wrote:
> On 10/24/06, James Edward Gray II <james@grayproductions.net> wrote:
>> On Oct 24, 2006, at 1:40 PM, Gregory Brown wrote:
>>
>> > irb(main):001:0> RUBY_PLATFORM
>> > => "i386-cygwin"
>>
>> It seems safer to target this one as an exception, rather than mswin,
>> so I'll go with that.
>>
>> One last question though, if Termios was installed for Cygwin would
>> it work OK there? I'm trying to figure out if I need to bypass
>> HighLine's search for that too.
>
> I have no idea how to install termios for Cygwin since it's not part
> of the standard distribution (i don't think), and I'm not really a
> Cygwin user.
>
> However, stty is included with Cygwin, so I think highline would work
> using that.
>
>

Just about anything that will compile and execute on Linux will compile
and execute on CygWin. However, since the Ruby community has deprecated
CygWin, I'm not sure why new code should do other than detect it and
complain. :)

When I run software on a Windows machine, my preference is for native
tools, with CygWin a "plan B" and a Gentoo virtual machine as "plan C".

Ara.T.Howard

10/25/2006 1:41:00 AM

0