# Errno::ENOENT and %x\[..\]

**URL:** <https://www.ruby-forum.com/t/errno-enoent-and-x/140512>\
**Category:** IronRuby\
**Created:** [June 15, 2008, 11:53am UTC](https://www.ruby-forum.com/t/errno-enoent-and-x/140512 "2008-06-15T11:53:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![murena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@murena](https://www.ruby-forum.com/u/murena)\
**Post date:** [June 15, 2008, 11:53am UTC](https://www.ruby-forum.com/t/errno-enoent-and-x/140512/1 "2008-06-15T11:53:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![murena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@murena](https://www.ruby-forum.com/u/murena)\
**Post date:** [June 15, 2008, 6:29pm UTC](https://www.ruby-forum.com/t/errno-enoent-and-x/140512/2 "2008-06-15T18:29:54Z")

</div>

%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: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Daniele  
Alessandri  
Sent: Sunday, June 15, 2008 2:53 AM  
To: removed\_email\_address@domain.invalid  
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 A.  
[http://www.clorophilla.net/blog/](http://www.clorophilla.net/blog/)
