From: Brian Candler Date: 2003-05-10T17:14:38+09:00 Subject: RCR for child execution Looking on RubyGarden it seems that the RCR process there is "resting", so here are is a suggestion for discussion: 1. A way to execute an external program capturing both stdout and stderr into a string Syntax might be: %X{prog args} # capital X This differs from %x{prog args 2>&1} because it seems that Windows doesn't support the latter syntax. At least, not according to the following code I have seen: tossErr = '' tossErr = ' 2>/dev/null' if RUBY_PLATFORM =~ /linux/ system ("dot -Tcmap #{dotName} -o #{mapName}" + tossErr) [taken from MiniRubyWiki. This is nasty and unportable because it doesn't do what is required on FreeBSD, Solaris etc.] 2. A variant of IO.popen which captures both stdout and stderr down the same pipe, maybe with an extra option letter: c = IO.popen("ls /foo","re") # unidirectional c = IO.popen("nroff -man","w+e") # bidirectional Again, this would be just to be more portable than 2>&1 Rather than an option letter, maybe Ruby should just look for "2>&1" at the end of the string, and if so strip it off and point the child's stdout and stderr to the same pipe? Then at least it could be relied on. Regards, Brian.