Mercurial > octave
comparison scripts/miscellaneous/ls.m @ 30955:cd741166d6fb
maint: merge stable to default.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 21 Apr 2022 12:04:09 -0700 |
parents | 230724ab2977 0acf9363da34 |
children | 98bff9749345 |
comparison
equal
deleted
inserted
replaced
30953:230724ab2977 | 30955:cd741166d6fb |
---|---|
36 ## It falls back to calling the native operating system's directory listing | 36 ## It falls back to calling the native operating system's directory listing |
37 ## command. Available @var{options} may vary from system to system. | 37 ## command. Available @var{options} may vary from system to system. |
38 ## | 38 ## |
39 ## Filenames are subject to shell expansion if they contain any wildcard | 39 ## Filenames are subject to shell expansion if they contain any wildcard |
40 ## characters @samp{*}, @samp{?}, @samp{[]}. If these wildcard characters are | 40 ## characters @samp{*}, @samp{?}, @samp{[]}. If these wildcard characters are |
41 ## escaped with a backslash @samp{\} (e.g., @samp{\*}), they aren't treated as | 41 ## escaped with a backslash @samp{\} (e.g., @samp{\*}) then they are not |
42 ## wildcards but as the corresponding literal character. | 42 ## treated as wildcards, but instead as the corresponding literal character. |
43 ## | 43 ## |
44 ## If the optional output @var{list} is requested then @code{ls} returns a | 44 ## If the optional output @var{list} is requested then @code{ls} returns a |
45 ## character array with one row for each file/directory name. | 45 ## character array with one row for each file/directory name. |
46 ## | 46 ## |
47 ## Example usage on a UNIX-like system: | 47 ## Example usage on a UNIX-like system: |
71 | 71 |
72 if (ispc () && ! isunix ()) | 72 if (ispc () && ! isunix ()) |
73 if (strncmp (ls_cmd, "ls", 2)) | 73 if (strncmp (ls_cmd, "ls", 2)) |
74 ## Replace backslashes with forward slashes (unless they escape a glob | 74 ## Replace backslashes with forward slashes (unless they escape a glob |
75 ## pattern) | 75 ## pattern) |
76 args = regexprep (args, '\\(?![\*\?\[\]])', '/'); | 76 args = regexprep (args, '\\(?![*?\[\]])', '/'); |
77 ## Enclose paths, potentially having spaces, in double quotes: | 77 ## Enclose paths, potentially having spaces, in double quotes: |
78 args = strcat ('"', args, '"'); | 78 args = strcat ('"', args, '"'); |
79 ## Exclude glob patterns and escaped characters from quoted part of | 79 ## Exclude glob patterns and escaped characters from quoted part of |
80 ## FILENAMES string | 80 ## FILENAMES string |
81 args = regexprep (args, '(?<!\\)([\*\?])', '"$1"'); | 81 args = regexprep (args, '(?<!\\)([*?])', '"$1"'); |
82 args = regexprep (args, '(?<!\\)\[', '"['); | 82 args = regexprep (args, '(?<!\\)\[', '"['); |
83 args = regexprep (args, '(?<!\\)\[', ']"'); | 83 args = regexprep (args, '(?<!\\)\[', ']"'); |
84 args = regexprep (args, '(\\.)', '"$1"'); | 84 args = regexprep (args, '(\\.)', '"$1"'); |
85 else | 85 else |
86 idx = ! strncmp (args, '/', 1); | 86 idx = ! strncmp (args, '/', 1); |