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:
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.
%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
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:
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.