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