[#2367] Standard libraries — Dave Thomas <dave@...>

From ruby-dev summary:

60 messages 2004/02/11

[#2397] PATCH: deprecate cgi-lib, getopts, importenv, parsearg from standard library — Gavin Sinclair <gsinclair@...>

Index: cgi-lib.rb

15 messages 2004/02/12

[#2465] PATCH: OpenStruct#initialize to yield self — Gavin Sinclair <gsinclair@...>

This is a common approach I use to object initialization; I don't know

24 messages 2004/02/19

Nested popens under OSX

From: Dave Thomas <dave@...>
Date: 2004-02-19 17:39:28 UTC
List: ruby-core #2467
The following code fails under OSX:

- - - - - - - - - -
code = %q{
   pipe = IO.popen("-","w+")
   if pipe
     pipe.puts "Get a job!"
     $stderr.puts "Child says '#{pipe.gets.chomp}'"
   else
     $stderr.puts "Dad says '#{gets.chomp}'"
     puts "OK"
   end
}

require 'rbconfig'

ruby = open("|ruby 2>&1", "w+")
ruby.puts code
ruby.close_write
result = ruby.readlines
ruby.close

puts result
- - - - - - - - - -

I get:

dave[Work/rubybook 11:33:33] ruby t.rb
-:7: private method `chomp' called for nil:NilClass (NoMethodError)
-:5: private method `chomp' called for nil:NilClass (NoMethodError)
dave[Work/rubybook 11:34:06] ruby t.rb
-:7: private method `chomp' called for nil:NilClass (NoMethodError)
-:4:in `write': Broken pipe (Errno::EPIPE)
         from -:4:in `puts'
         from -:4

However it works fine under Linux.

If I run just the code in 'code' it works fine.

Am I doing something stupid (the likely case), or is there a problem 
running popen inside a process that's run using popen?


Cheers

Dave


In This Thread

Prev Next