Message330417
In short, `fnmatch.fnmatch` doesn't match shell result. To test this, create a dir with 2 files: `a.py` and `b.py`. Then `ls [!b].py` and `ls [^b].py` will both show `a.py`. However, `fnmatch.fnmatch('a.py', '[!b].py')` returns `True` but `fnmatch.fnmatch('a.py', '[^b].py')` returns `False`.
Problem seems to come from an escaped caret: https://github.com/python/cpython/blob/master/Lib/fnmatch.py#L124
I don't see why caret and exclamation mark are different from `man bash`:
> ...If the first character following the [ is a ! or a ^ then any character not enclosed is matched...
Could someone please confirm it's a bug or intended behavior? |
|
Date |
User |
Action |
Args |
2018-11-26 10:58:12 | cykerway | set | recipients:
+ cykerway |
2018-11-26 10:58:12 | cykerway | set | messageid: <1543229892.22.0.788709270274.issue35314@psf.upfronthosting.co.za> |
2018-11-26 10:58:12 | cykerway | link | issue35314 messages |
2018-11-26 10:58:12 | cykerway | create | |
|