Mercurial > octave-dspies
annotate scripts/miscellaneous/ls.m @ 11547:e1851653d59c
Eliminate @deffn macros.
For consistency and easier maintenance, only use @deftypefn macro.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 15 Jan 2011 10:04:30 -0800 |
parents | fd0a3ac60b0e |
children | c792872f8942 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2006-2011 John W. Eaton |
6115 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6115 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6115 | 18 |
19 ## -*- texinfo -*- | |
11547 | 20 ## @deftypefn {Command} {} ls options |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
21 ## List directory contents. For example: |
6115 | 22 ## |
23 ## @example | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
24 ## @group |
6115 | 25 ## ls -l |
26 ## @print{} total 12 | |
27 ## @print{} -rw-r--r-- 1 jwe users 4488 Aug 19 04:02 foo.m | |
28 ## @print{} -rw-r--r-- 1 jwe users 1315 Aug 17 23:14 bar.m | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
29 ## @end group |
6115 | 30 ## @end example |
31 ## | |
32 ## The @code{dir} and @code{ls} commands are implemented by calling your | |
33 ## system's directory listing command, so the available options may vary | |
34 ## from system to system. | |
35 ## @seealso{dir, stat, readdir, glob, filesep, ls_command} | |
11547 | 36 ## @end deftypefn |
6115 | 37 |
38 ## Author: jwe | |
39 | |
40 function retval = ls (varargin) | |
41 | |
42 global __ls_command__; | |
43 | |
44 if (isempty (__ls_command__) || ! ischar (__ls_command__)) | |
45 ## Initialize value for __ls_command__. | |
46 ls_command (); | |
47 endif | |
48 | |
49 if (iscellstr (varargin)) | |
50 | |
51 args = tilde_expand (varargin); | |
52 | |
53 cmd = sprintf ("%s ", __ls_command__, args{:}); | |
54 | |
6943 | 55 if (page_screen_output () || nargout > 0) |
6115 | 56 |
57 [status, output] = system (cmd); | |
58 | |
59 if (status == 0) | |
10549 | 60 if (nargout == 0) |
61 puts (output); | |
62 else | |
11032
c9b0a75b02e8
Make all regexp in Octave compatible with both POSIX and PCRE.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
63 retval = strvcat (regexp (output, '\S+', 'match'){:}); |
10549 | 64 endif |
6115 | 65 else |
10549 | 66 error ("ls: command exited abnormally with status %d", status); |
6115 | 67 endif |
68 | |
69 else | |
70 ## Just let the output flow if the pager is off. That way the | |
71 ## output from things like "ls -R /" will show up immediately and | |
72 ## we won't have to buffer all the output. | |
73 system (cmd); | |
74 endif | |
75 | |
76 else | |
77 error ("ls: expecting all arguments to be character strings"); | |
78 endif | |
79 | |
80 endfunction | |
7411 | 81 |
82 %!error ls (1); | |
83 |