Mercurial > octave
changeset 27190:8ebe70b98e97
cd: only change to home directory if nargin and nargout are zero (bug #41275)
* dirfns.cc: Only cd to home if nargin and nargout are both zero.
* system.tst: New test for cd.
author | Michael C. Grant <mcg@cvxr.com> |
---|---|
date | Mon, 17 Jun 2019 11:12:52 -0500 |
parents | 946c6f117091 |
children | 0ad2ff3a3a6e |
files | libinterp/corefcn/dirfns.cc test/system.tst |
diffstat | 2 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/dirfns.cc Sat Jun 15 11:04:52 2019 -0500 +++ b/libinterp/corefcn/dirfns.cc Mon Jun 17 11:12:52 2019 -0500 @@ -97,12 +97,13 @@ doc: /* -*- texinfo -*- @deftypefn {} {} cd @var{dir} @deftypefnx {} {} cd +@deftypefnx {} {@var{old_dir} =} cd @deftypefnx {} {@var{old_dir} =} cd (@var{dir}) @deftypefnx {} {} chdir @dots{} Change the current working directory to @var{dir}. -If @var{dir} is omitted, the current directory is changed to the user's home -directory (@qcode{"~"}). +If called with no input or output arguments, the current directory is +changed to the user's home directory (@qcode{"~"}). For example, @@ -140,7 +141,7 @@ if (! dirname.empty ()) octave_change_to_directory (dirname); } - else + else if (nargout == 0) { std::string home_dir = octave::sys::env::get_home_directory ();