Mercurial > hg > octave-terminal
changeset 483:41a70d08c1f7
[project @ 1994-06-30 18:30:21 by jwe]
author | jwe |
---|---|
date | Thu, 30 Jun 1994 18:31:46 +0000 |
parents | 680426c10c5e |
children | e19ec79471e3 |
files | src/g-builtins.cc src/procstream.cc src/procstream.h |
diffstat | 3 files changed, 24 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/g-builtins.cc +++ b/src/g-builtins.cc @@ -1592,29 +1592,29 @@ { tree_constant *retval = NULL_TREE_CONST; - if (nargin == 2 || nargin == 3) + if (nargin == 2 && args[1].is_string_type ()) { - if (args[1].is_string_type ()) + iprocstream cmd (args[1].string_value ()); + char ch; + ostrstream output_buf; + while (cmd.get (ch)) + output_buf.put (ch); + output_buf << ends; + int status = cmd.close (); + switch (nargout) { - iprocstream cmd (args[1].string_value ()); - char ch; - ostrstream output_buf; - while (cmd.get (ch)) - output_buf.put (ch); - - output_buf << ends; - if (nargin == 2) - { - maybe_page_output (output_buf); - } - else - { - retval = new tree_constant [2]; - retval[0] = tree_constant (output_buf.str ()); - } + case 1: + maybe_page_output (output_buf); + retval = new tree_constant[1]; + retval[0] = tree_constant ((double) status); + break; + case 2: + retval = new tree_constant[3]; + retval[0] = tree_constant ((double) status); + retval[1] = tree_constant (output_buf.str ()); + break; + break; } - else - error ("shell_cmd: first argument must be a string"); } else print_usage ("shell_cmd");