Skip to content

Commit a988359

Browse files
rasatomasz1986
andauthored
feat(users/ignoring): add escaping on Windows (#919)
Ref syncthing/syncthing#10058 --------- Co-authored-by: tomasz1986 <[email protected]>
1 parent a86f6a1 commit a988359

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

users/faq-parts/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ files ``qax``, ``qbx`` and ``qcx``.
116116
To match an actual file *called* ``q[abc]x`` the pattern needs to "escape"
117117
the brackets, like so: ``q\[abc\]x``.
118118

119-
On Windows, escaping special characters is not supported as the ``\``
119+
On Windows, use the ``|`` character to escape the brackets (``q|[abc|]x``), as the ``\``
120120
character is used as a path separator.
121121

122122
How do I access the web GUI from another computer?

users/ignoring.rst

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,26 @@ The ``.stignore`` file contains a list of file or path patterns. The
6363

6464
.. note::
6565

66-
Escaped characters are not supported on Windows, where ``\`` is the
67-
path separator. If you still need to match files that have square or
68-
curly brackets in their names, one possible workaround is to replace
69-
them with ``?``, which will then match any character. For example,
70-
you can type ``?banana?`` to match both ``[banana]`` and
71-
``{banana}``, and so on.
66+
On Windows, ``\`` is the path separator, so use ``|`` to escape special
67+
characters. For example, ``|{banana|}`` matches
68+
``{banana}``.
69+
70+
To use ``\`` to escape special characters (and use ``/`` as the path separator),
71+
insert a ``#escape=\`` at the top of the file. Here's a short example:
72+
73+
| ``#escape=\``
74+
| ``/foo``
75+
| ``/path/bar/\{banana\}``
76+
| ``/path/baz\[2\]/ex\[3\].txt``
77+
78+
``#escape=\`` must be placed at the top of the file, before any patterns,
79+
but leading comments, and blank lines are OK.
80+
81+
Any files included using ``#include`` (see below) will each need their
82+
own ``#escape=\``.
83+
84+
Using ``#escape=\`` allows the same file to be synced and used on any
85+
operating system.
7286

7387
- A pattern beginning with ``/`` matches in the root of the synced folder only.
7488
``/foo`` matches ``foo`` but not ``subdir/foo``.
@@ -190,3 +204,10 @@ all files and directories called "foo", ending in a "2" or starting with
190204
accepting a folder from a remote device. The GUI suggests the same patterns
191205
when adding a folder manually. In either case, the ``.stignore`` file is
192206
created with these defaults if none is present yet.
207+
208+
.. versionadded:: 2.0.0
209+
210+
Windows users can now use the pipe character (``|``) to escape
211+
metacharacters in the ``.stignore`` file. Additionally, adding
212+
``#escape=X`` to the top of the file, allows users to define ``X``
213+
as the escape character for that particular file.

0 commit comments

Comments
 (0)