Message330481
Thank you for confirmation. Knowing it is not fully POSIX-compliant helps with understanding.
I'm asking this because I had interoperability issues writing python scripts providing shell-like utilities for filename expansion and the result may surprise users. The glibc fnmatch provides a flag named `FNM_PATHNAME`, which is missing in the python fnmatch implementation. So I think there is currently no way to tell the python library if we are matching a filename or not.
All right so this is not a bug, but probably a good enhancement.
## TLDR
This is what POSIX says **for filename expansion**, in section 2.13.3:
<http://pubs.opengroup.org/onlinepubs/9699919799.2008edition/>
> when pattern matching notation is used for filename expansion:
>
> 1. The <slash> character in a pathname shall be explicitly matched by using one or more <slash> characters in the pattern; it shall neither be matched by the <asterisk> or <question-mark> special characters nor by a bracket expression. <slash> characters in the pattern shall be identified before bracket expressions; thus, a <slash> cannot be included in a pattern bracket expression used for filename expansion. If a <slash> character is found following an unescaped <left-square-bracket> character before a corresponding <right-square-bracket> is found, the open bracket shall be treated as an ordinary character. For example, the pattern "a[b/c]d" does not match such pathnames as abd or a/d. It only matches a pathname of literally a[b/c]d.
Currently python fnmatch.fnmatch gives:
>>> fnmatch('abd', 'a[b/c]d')
True
>>> fnmatch('a/d', 'a[b/c]d')
True
>>> fnmatch('a[b/c]d', 'a[b/c]d')
False
Ideally we can call `fnmatch('a/d', 'a[b/c]d', fnm_pathname=True)` to correct the behavior. |
|
Date |
User |
Action |
Args |
2018-11-26 23:30:16 | cykerway | set | recipients:
+ cykerway, serhiy.storchaka, josh.r, xtreak |
2018-11-26 23:30:16 | cykerway | set | messageid: <1543275016.33.0.788709270274.issue35314@psf.upfronthosting.co.za> |
2018-11-26 23:30:16 | cykerway | link | issue35314 messages |
2018-11-26 23:30:16 | cykerway | create | |
|