Repository: sharkdp/fd (language: rust)

Issue:
No good way to use a regex that starts with a hyphen (-)
grep provides the `-e` flag, partly so that you can protect patterns that start with "-". afaict, fd doesn't have such a mechanism, and the best way I can think of to search for such a pattern would be to search for something like `.?-<whatever>`. At the very least there should be documentation on how to deal with this scenario.


Discussion / hints:
Doesn't this work?

```bash
fd -- '-yourpattern'
```

To avoid all leading `-` to be interpreted as arguments, most unix tools support `--` (stop interpreting `-` arguments as flags):

```
$ mkdir /tmp/test_fd_leading_hypen
$ cd /tmp/test_fd_leading_hypen

# Create some files.
$ echo bla1 > -file1
$ echo bla2 > another-file2
$ echo bla3 > file3

# List files.
$ fd
-file1
another-file2
file3

# Find files.
$ fd -- -f
-file1
another-file2

# Remove files ("--" to avoid "-file1" be processed as flags).
$ rm -- -file1 another-file2 file3
```
There's also `fd '[-]whatever'` and `fd '\-whatever'`

Fix patch:
diff --git a/README.md b/README.md
index c309dff6c..5018980f3 100644
--- a/README.md
+++ b/README.md
@@ -340,6 +340,15 @@ testenv/mod.rs
 tests.rs
 ```
 
+If you want to use this functionality to list all files in a given directory, you have to use
+a catch-all pattern such as `.` or `^`:
+``` bash
+> fd . fd/tests/
+testenv
+testenv/mod.rs
+tests.rs
+```
+
 ### Searching for a particular file extension
 
 Often, we are interested in all files of a particular type. This can be done with the `-e` (or
@@ -418,6 +427,35 @@ If we want to run a command on all search results, we can pipe the output to `xa
 Here, the `-0` option tells *fd* to separate search results by the NULL character (instead of
 newlines). In the same way, the `-0` option of `xargs` tells it to read the input in this way.
 
+### Troubleshooting
+
+#### `fd` does not find my file!
+
+Remember that `fd` ignores hidden directories and files by default. It also ignores patterns
+from `.gitignore` files. If you want to make sure to find absolutely every possible file, always
+use the options `-H` and `-I` to disable these two features:
+``` bash
+> fd -HI …
+```
+
+#### `fd` doesn't seem to interpret my regex pattern correctly
+
+A lot of special regex characters (like `[]`, `^`, `$`, ..) are also special characters in your
+shell. If in doubt, always make sure to put single quotes around the regex pattern:
+
+``` bash
+> fd '^[A-Z][0-9]+$'
+```
+
+If your pattern starts with a dash, you have to add `--` to signal the end of command line
+options. Otherwise, the pattern will be interpreted as a command-line option. Alternatively,
+use a character class with a single hyphen character:
+
+``` bash
+> fd -- '-pattern'
+> fd '[-]pattern'
+```
+
 ### Integration with other programs
 
 #### Using fd with `fzf`


Test patch: