Skip to content

Commit 6e0f276

Browse files
committed
feat(users/ignoring): Add escaping on Windows
Ref syncthing/syncthing#10058
1 parent bd61896 commit 6e0f276

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-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: 20 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``.

0 commit comments

Comments
 (0)