[Ironruby-core] A few things about system and IO.popen - what's the current status ?

Tomas Matousek Tomas.Matousek at microsoft.com
Wed Mar 4 11:42:23 EST 2009


Implementations of both "system" and "popen" are not solid. Any help here is very much appreciated! Feel free to submit patches and also new specs for these methods. Let us know if you need some changes in runtime (IronRuby.dll) since this assembly is not open to contributions just yet (but we might be able to factor some stuff out to libraries or provide the necessary functionality needed in core).

BTW, our tag file for Kernel#system contains this suppressions:

fails:Kernel#system can run basic things that exist
fails:Kernel#system returns false when it can't
fails:Kernel#system does not write to stderr when it can't find a command
fails:Kernel#system uses /bin/sh if freaky shit is in the command
fails:Kernel#system is a private method
fails:Kernel#system expands shell variables when given a single string argument
fails:Kernel#system does not expand shell variables when given multiples arguments

Tomas

From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Thibaut Barrère
Sent: Wednesday, March 04, 2009 3:37 AM
To: ironruby-core
Subject: [Ironruby-core] A few things about system and IO.popen - what's the current status ?

Hi,

sorry if it's a know fact - I could not find the info easily. I hope this will be useful.

On Windows, system() seems to work partially, is it normal ? The following works:

>>> system("echo hello")
hello
=> true

the following doesn't seem to (although svn is in the path):

>>> system("svn")
=> false
>>> system("svn.exe")
=> false

Still on Windows, it seems that IO.popen crashes (I had a quick look at IoOps.cs to see if it was implemented):

>>> IO.popen("svn.exe") do |io| puts io.read end
:0:in `popen': La référence d'objet n'est pas définie à une instance d'un objet. (System::NullReferenceException)
       from :0:in `popen'
       from :0

I ran the same stuff on Mono and got:

IronRuby 1.0.0.0 on Mono 2.4
Copyright (c) Microsoft Corporation. All rights reserved.

>>> system("blah")
IronRuby.Libraries:0:in `ExecuteProcessAndWait': No such file or directory (Errno::ENOENT)
from IronRuby.Libraries:0:in `ExecuteCommandInShell'
from :0:in `system'

>>> system("svn")
=> nil
>>> system("svn > svninfo.txt")
=> nil
>>> exit

Finally, running IO.popen on Mono gives the same output as Windows:

IronRuby 1.0.0.0 on Mono 2.4
Copyright (c) Microsoft Corporation. All rights reserved.

>>> IO.popen("svn.exe") { |io| puts io.read }
:0:in `popen': Object reference not set to an instance of an object (System::NullReferenceException)
     from :0:in `popen'


So my question is: what's the current status on system and IO.popen ? Is it supposed to work and is it a regression, or is it not fully implemented ?

I may be able to help at some point here (either by providing patches or testing on Mono + Windows) if it's not your top priority :)

Given that I use Ruby to glue things together quite a lot, that would be useful to me.

cheers,

-- Thibaut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090304/1a49db42/attachment-0001.html>


More information about the Ironruby-core mailing list