[Ironruby-core] Errno::ENOENT and %x[..]

Tomas Matousek Tomas.Matousek at microsoft.com
Sun Jun 15 12:29:00 EDT 2008


%x and ` should be compiled to a dynamic call of Kernel#`. So you can entirely implement the feature in libraries. Send a patch as soon as you’ll have something ready. I’ll make the compiler to emit the right call.

irb(main):007:0> module Kernel
irb(main):008:1>   def ` x
irb(main):009:2>      puts '`'
irb(main):010:2>   end
irb(main):011:1> end
=> nil
irb(main):012:0> `dir`
`
=> nil
irb(main):013:0> %x{dir}
`
=> nil

Tomas

From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Daniele Alessandri
Sent: Sunday, June 15, 2008 2:53 AM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Errno::ENOENT and %x[..]

Hi,

Last month, in my spare time, I have started to implement Process::Status and the related methods Kernel#system, Kernel#exec and %x[..]. While trying to solve a few design issues on my side, I noticed that %x[..] behaves like Kernel#exec in that they both throw exceptions:

ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

irb(main):001:0> system "doesnotexist"
=> false
irb(main):002:0> exec "doesnotexist"
Errno::ENOENT: No such file or directory - doesnotexist
        from (irb):2:in `exec'
        from (irb):2
irb(main):003:0> %x[doesnotexist]
Errno::ENOENT: No such file or directory - doesnotexist
        from (irb):3:in ``'
        from (irb):3
irb(main):004:0>

Now the problem is that the implementation of %x[..] is in the Ruby project (more precisely, in the static method ExecuteCommand of RubyOps) while the NoEntryError exception (Errno::ENOENT) is defined in the IronRuby.Libraries project and thus not accessible AFAIK.

Any ideas on how to work around this?

--
Daniele Alessandri
http://www.clorophilla.net/blog/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080615/0247da14/attachment.html>


More information about the Ironruby-core mailing list