From 36dc96339e2b2b692e6dfe6de43db3a2348732bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 14 Sep 2017 12:52:02 +0200 Subject: Implement escaping of special characters in wildcards Allow characters with special meaning to be escaped using \ (which must be writen as \\ in a string). That allows matching of filenames containing characters that are special in wildcards. This is an incompatible change, but note that the use of backslashes in wildcards would already work differently on Windows and Unix. Take for example this call: filelib:wildcard("a\\b") On Windows, filelib:wildcard/1 would look for a directory named "a", and a file or directory named "b" inside it. On Unix, filelib:wildcard/1 would look for a file named "a\\b". With this commit applied, filelib:wildcard/1 will look for a file named "ab" on both Windows and Unix. https://bugs.erlang.org/browse/ERL-451 --- lib/stdlib/doc/src/filelib.xml | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/stdlib/doc') diff --git a/lib/stdlib/doc/src/filelib.xml b/lib/stdlib/doc/src/filelib.xml index 57c4348745..1b69e84d31 100644 --- a/lib/stdlib/doc/src/filelib.xml +++ b/lib/stdlib/doc/src/filelib.xml @@ -217,6 +217,11 @@

Other characters represent themselves. Only filenames that have exactly the same character in the same position match. Matching is case-sensitive, for example, "a" does not match "A".

+

Directory separators must always be written as /, even on + Windows.

+

A character preceded by \ loses its special meaning. Note + that \ must be written as \\ in a string literal. + For example, "\\?*" will match any filename starting with ?.

Notice that multiple "*" characters are allowed (as in Unix wildcards, but opposed to Windows/DOS wildcards).

Examples:

-- cgit v1.2.3