changeset 30953:230724ab2977

maint: Merge stable to default.
author Markus Mützel <markus.muetzel@gmx.de>
date Thu, 21 Apr 2022 18:32:33 +0200
parents 9d7ec294af2b (current diff) c09fdabaa5b6 (diff)
children cd741166d6fb
files scripts/miscellaneous/dir.m scripts/miscellaneous/ls.m
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/dir.m	Thu Apr 21 17:54:21 2022 +0200
+++ b/scripts/miscellaneous/dir.m	Thu Apr 21 18:32:33 2022 +0200
@@ -61,9 +61,13 @@
 ## than a single directory or file.
 ##
 ## @var{directory} is subject to shell expansion if it contains any wildcard
-## characters @samp{*}, @samp{?}, @samp{[]}.  To find a literal example of a
-## wildcard character the wildcard must be escaped using the backslash operator
-## @samp{\}.
+## characters @samp{*}, @samp{?}, @samp{[]}.  If these wildcard characters are
+## escaped with a backslash @samp{\} (e.g., @samp{\*}) on a POSIX platform,
+## they aren't treated as wildcards but as the corresponding literal character.
+## On Windows, it is not possible to escape wildcard characters because
+## backslash @samp{\} is treated as a file separator.  On Windows, use
+## @code{ls} instead for file or folder names that contain characters that
+## would be treated as wildcards by @code{dir}.
 ##
 ## Note that for symbolic links, @code{dir} returns information about the
 ## file that the symbolic link points to rather than the link itself.
--- a/scripts/miscellaneous/ls.m	Thu Apr 21 17:54:21 2022 +0200
+++ b/scripts/miscellaneous/ls.m	Thu Apr 21 18:32:33 2022 +0200
@@ -76,10 +76,12 @@
         args = regexprep (args, '\\(?![\*\?\[\]])', '/');
         ## Enclose paths, potentially having spaces, in double quotes:
         args = strcat ('"', args, '"');
-        ## Exclude glob patterns from quoted part of FILENAMES string
+        ## Exclude glob patterns and escaped characters from quoted part of
+        ## FILENAMES string
         args = regexprep (args, '(?<!\\)([\*\?])', '"$1"');
         args = regexprep (args, '(?<!\\)\[', '"[');
         args = regexprep (args, '(?<!\\)\[', ']"');
+        args = regexprep (args, '(\\.)', '"$1"');
       else
         idx = ! strncmp (args, '/', 1);
         ## Enclose paths, potentially having spaces, in double quotes: