view scripts/deprecated/shell_cmd.m @ 16724:b7667fcb9fbc

Substitute ostrsplit() for strsplit(). The function ostrsplit() is Octave's original strsplit(), and strsplit() has been modified to be compatible with Matlab's version. Bug #39010. * scripts/deprecated/javafields.m: Change call to ostrsplit(). * scripts/deprecated/javamethods.m: ditto * scripts/general/fieldnames.m: ditto * scripts/general/int2str.m: ditto * scripts/general/methods.m: ditto * scripts/general/num2str.m: ditto * scripts/help/gen_doc_cache.m: ditto * scripts/help/help.m: ditto * scripts/help/lookfor.m: ditto * scripts/io/strread.m: ditto * scripts/java/javaclasspath.m: ditto * scripts/miscellaneous/compare_versions.m: ditto * scripts/miscellaneous/computer.m: ditto * scripts/miscellaneous/fact.m: ditto * scripts/miscellaneous/tar.m: ditto * scripts/miscellaneous/unpack.m: ditto * scripts/miscellaneous/what.m: ditto * scripts/miscellaneous/zip.m: ditto * scripts/pkg/private/configure_make.m: ditto * scripts/pkg/private/fix_depends.m: ditto * scripts/pkg/private/generate_lookfor_cache.m: ditto * scripts/pkg/private/list_forge_packages.m: ditto * scripts/pkg/private/unload_packages.m: ditto * scripts/pkg/private/write_index.m: ditto * scripts/plot/private/__file_filter__.m: ditto * scripts/plot/private/__fltk_file_filter__.m: ditto * scripts/plot/private/__go_draw_axes__.m: ditto * scripts/plot/private/__next_line_style__.m: ditto * scripts/testfun/rundemos.m: ditto * scripts/testfun/runtests.m: ditto
author Ben Abbott <bpabbott@mac.com>
date Thu, 06 Jun 2013 10:06:12 +0800
parents 72c96de7a403
children bc924baa2c4e
line wrap: on
line source

## Copyright (C) 2012 Rik Wehbring
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or (at
## your option) any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, see
## <http://www.gnu.org/licenses/>.

## "-*- texinfo -*-
## @deftypefn  {Built-in Function} {} shell_cmd (@var{string})
## @deftypefnx {Built-in Function} {} shell_cmd (@var{string}, @var{return_output})
## @deftypefnx {Built-in Function} {} shell_cmd (@var{string}, @var{return_output}, @var{type})
## @deftypefnx {Built-in Function} {[@var{status}, @var{output}] =} shell_cmd (@dots{})
## @deftypefnx {Built-in Function} {[@var{status}, @var{output}] =} shell_cmd (@var{string}, @var{return_output}, @var{type})
## Execute a shell command specified by @var{string}.
## If the optional argument @var{type} is "async", the process
## is started in the background and the process id of the child process
## is returned immediately.  Otherwise, the process is started and
## Octave waits until it exits.  If the @var{type} argument is omitted, it
## defaults to a value of "sync".
## 
## If the optional argument @var{return_output} is true and the subprocess
## is started synchronously, or if @var{shell_cmd} is called with one input
## argument and one or more output arguments, then the output from the command
## is returned.  Otherwise, if the subprocess is executed synchronously, its
## output is sent to the standard output.
##
## The @code{shell_cmd} function can return two values.  The first is the
## exit status of the command and the second is any output from the
## command that was written to the standard output stream.  For example,
## 
## @example
## [status, output] = shell_cmd ("echo foo; exit 2");
## @end example
## 
## @noindent
## will set the variable @code{output} to the string @samp{foo}, and the
## variable @code{status} to the integer @samp{2}.
## 
## For commands run asynchronously, @var{status} is the process id of the
## command shell that is started to run the command.
## @seealso{system, unix, dos}
## @end deftypefn

## Deprecated in version 3.6

function [status, output] = shell_cmd (varargin)
  persistent warned = false;
  if (! warned)
    warned = true;
    warning ("Octave:deprecated-function",
             "shell_cmd is obsolete and will be removed from a future version of Octave; please use system instead");
  endif

  [status, output] = system (varargin{:});

endfunction