notes: add Pattern Matching section

This commit is contained in:
Khaïs COLIN 2025-02-07 15:41:09 +01:00
parent 2cdd540ed7
commit 1640914ea0
No known key found for this signature in database

View file

@ -242,7 +242,30 @@ When a pattern is used for filename expansion, the character '.' at the start of
a filename or immediately following a slash must be matched explicitly. In order a filename or immediately following a slash must be matched explicitly. In order
to match the filenames '.' and '..', the pattern must begin with '.' to match the filenames '.' and '..', the pattern must begin with '.'
When matching a filename, the slash character must always be matched explicitly
by a slash in the pattern.
##### Pattern Matching
cf. 3.5.8.1 Pattern Matching
Any character that appears in a pattern, other than the special pattern
characters described below, matches itself. The NUL character may not occur in
a pattern.
The special pattern characters have the following meanings:
'\*'
Matches any string, including the null string.
The special pattern characters must be quoted if they are to be matched
literally.
e.g. this is the required behaviour
```shell
bash-5.1$ ls *there
'hello*there' 'hi*there' noonethere
bash-5.1$ ls *'*'there
'hello*there' 'hi*there'
```
#### Quote Removal #### Quote Removal
TODO TODO