Bug or feature in Ruby (1.80.pre4)

G

Gour

Hi!

While attempting to compile and tweak extconf.rb for wxruby bindings
I've discovered that backticking gives different results in Linux and in
MinGW & MSYS environment.

Here is the result:

ggd@gaura:~> ruby -v
ruby 1.8.0 (2003-07-24) [i686-linux]
ggd@gaura:~> cat t.rb
puts `wx-config --cxx`
ggd@gaura:~> ruby t.rb
c++
ggd@gaura:~> irb
irb(main):001:0> `wx-config --cxx`
=> "c++\n"

The same is if I use:

ggd@gaura:~> cat t.rb
puts %x(wx-config --cxx)


However under Win platform & MSYS environment which uses POSIX notation:

ggd@GGD ~
$ ruby -v
ruby 1.8.0 (2003-07-24) [i386-mingw32]

ggd@GGD ~
$ ruby t.rb
t.rb:1:in ``': No such file or directory - wx-config --cxx (Errno::ENOENT)
from t.rb:1

ggd@GGD ~
$ irb
irb(main):001:0> `wx-config --cxx`
`wx-config --cxx`
Errno::ENOENT: No such file or directory - wx-config --cxx
from (irb):1:in ``'
from (irb):1

$ wx-config --cxx
c++


The same error if I use %x delimiter instead of backtick.

Is it a Ruby bug?

The Ruby cannot find shell script wx-config, although it is in the PATH (/mingw/bin).

Here is the output for PATH variable:

from MSYS (shell):

$ echo $PATH
.:/usr/local/bin:/mingw/bin:/bin:/mingw/BIN:/mingw/LIB:/j/DOS:/j/MERGE:/c/WINDOWS:/c/WINDOWS/COMMAND:.

from Ruby:

$ ruby t.rb
.;C:\MSYS\1.0\local\bin;c:\MinGW\bin;C:\MSYS\1.0\BIN;c:\MinGW\BIN;c:\MinGW\LIB;j:\DOS;j:\MERGE;c:\WINDOWS;c:\WINDOWS\COMMAND;.


from irb:

$ irb
irb(main):001:0> ENV['PATH']
ENV['PATH']
=> ".;C:\\MSYS\\1.0\\local\\bin;c:\\MinGW\\bin;C:\\MSYS\\1.0\\BIN;c:\\MinGW\\BIN;c:\\MinGW\\LIB;j:\\DOS;j:\\MERGE;c:\\WINDOWS;c:\\WINDOWS\\COMMAND;."
irb(main):002:0>

Is it normal behaviour?

Under Linux, all three cases gives identical result.

Sincerely,
Gour
 
W

WATANABE Hirofumi

Hi,

Gour said:
However under Win platform & MSYS environment which uses POSIX notation:

ggd@GGD ~
$ ruby -v
ruby 1.8.0 (2003-07-24) [i386-mingw32]

ggd@GGD ~
$ ruby t.rb
t.rb:1:in ``': No such file or directory - wx-config --cxx (Errno::ENOENT)
from t.rb:1

ggd@GGD ~
$ irb
irb(main):001:0> `wx-config --cxx`
`wx-config --cxx`
Errno::ENOENT: No such file or directory - wx-config --cxx
from (irb):1:in ``'
from (irb):1

$ wx-config --cxx
c++


The same error if I use %x delimiter instead of backtick.

Is it a Ruby bug?

No. MinGW ruby is a navite win32 application. It does not
recognize shell script like mswin32 ruby.

watanabe@PORTER ~/ruby/msys
$ ruby -v
ruby 1.8.0 (2003-07-29) [i386-mingw32]

watanabe@PORTER ~/ruby/msys
$ printf "#! /bin/sh\necho Hello" >/bin/foo

watanabe@PORTER ~/ruby/msys
$ foo
Hello

watanabe@PORTER ~/ruby/msys
$ ruby -e 'p `foo`'
-e:1:in ``': No such file or directory - foo (Errno::ENOENT)
from -e:1

watanabe@PORTER ~/ruby/msys
$ ruby -e 'p `sh foo`'
"Hello\n"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top