comparison scripts/miscellaneous/ls_command.m @ 6115:bade9ff1814b

[project @ 2006-10-27 17:58:06 by jwe]
author jwe
date Fri, 27 Oct 2006 17:58:06 +0000
parents
children 45e37d4f324e
comparison
equal deleted inserted replaced
6114:a0dafb51dd06 6115:bade9ff1814b
1 ## Copyright (C) 2006 John W. Eaton
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2, or (at your option)
8 ## any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, write to the Free
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 ## 02110-1301, USA.
19
20 ## -*- texinfo -*-
21 ## @deftypefn {Function File} {[@var{old_cmd} =} ls_command (@var{cmd})
22 ## Set or return the shell command used by Octave's @code{ls} command.
23 ## The value of @var{cmd} must be a character string.
24 ## With no arguments, simply return the previous value.
25 ## @seealso{ls}
26 ## @end deftypefn
27
28 ## Author: jwe
29
30 function old_cmd = ls_command (cmd)
31
32 global __ls_command__;
33
34 if (isempty (__ls_command__))
35 ## FIXME -- ispc and isunix both return true for Cygwin. Should they?
36 if (ispc () && ! isunix () && isempty (file_in_path (EXEC_PATH, "ls")))
37 __ls_command__ = "cmd /C dir /w";
38 else
39 __ls_command__ = "ls -C";
40 endif
41 endif
42
43 if (nargin == 0 || nargin == 1)
44
45 old_cmd = __ls_command__;
46
47 if (nargin == 1)
48 if (ischar (cmd))
49 __ls_command__ = cmd;
50 else
51 error ("ls_command: expecting argument to be a character string");
52 endif
53 endif
54
55 endif
56
57 endfunction