/* * call-seq: * `cmd` => string * * Returns the standard output of running _cmd_ in a subshell. * The built-in syntax <code>%x{...}</code> uses * this method. Sets <code>$?</code> to the process status. * * `date` #=> "Wed Apr 9 08:56:30 CDT 2003\n" * `ls testdir`.split[1] #=> "main.rb" * `echo oops && exit 99` #=> "oops\n" * $?.exitstatus #=> 99 */ static VALUE rb_f_backquote(obj, str) VALUE obj, str; { volatile VALUE port; VALUE result; OpenFile *fptr; SafeStringValue(str); port = pipe_open(str, 0, "r"); if (NIL_P(port)) return rb_str_new(0,0); GetOpenFile(port, fptr); result = read_all(fptr, remain_size(fptr), Qnil); rb_io_close(port); return result; }