From 1640914ea0e69d2962a282433f61c41eebaadd61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Fri, 7 Feb 2025 15:41:09 +0100 Subject: [PATCH] notes: add Pattern Matching section --- NOTES.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/NOTES.md b/NOTES.md index 717c529..f254be7 100644 --- a/NOTES.md +++ b/NOTES.md @@ -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 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 TODO