Skip to content

** wildcard doesnt match "none" #5

@mulawamichal

Description

@mulawamichal

consider some dir tree on linux

$ tree
.
├── a-1
│   ├── b-1
│   │   └── c-1
│   │       └── d-1
│   ├── b-2
│   │   ├── c-1
│   │   └── some
│   │       ├── garbage
│   │       │   └── c-1
│   │       └── more
│   │           └── garbage
│   │               └── c-1
│   └── c-1
└── a-10
    ├── b-1
    │   └── c-1
    └── b-2
        └── c-1

now lets do some bash globbing:

$ ls -1d a-1/*/c*
a-1/b-1/c-1
a-1/b-2/c-1

and using globstar:

$ (shopt -s globstar; ls -1d a-1/**/c*)
a-1/b-1/c-1
a-1/b-2/c-1
a-1/b-2/some/garbage/c-1
a-1/b-2/some/more/garbage/c-1
a-1/c-1

notice that apart of the obvious parts - so matching the c-1 in all possible subdirectories, it also matches the direct child dir

a-1/c-1

unfortunately, this is not the case with pywildcard:

$ dirs=(
> /a-10/b-1/c-1
> /a-10/b-2/c-1
> /a-1/b-1/c-1
> /a-1/b-2/c-1
> /a-1/b-2/some/garbage/c-1
> /a-1/b-2/some/more/garbage/c-1
> /a-1/c-1
> )
$ python3 -c "import sys, pywildcard; print(pywildcard.filter(sys.argv, '/a-1/*/c-1'))" "${dirs[@]}"
['/a-1/b-1/c-1', '/a-1/b-2/c-1']
$ python3 -c "import sys, pywildcard,pprint; pprint.pprint(pywildcard.filter(sys.argv, '/a-1/**/c-1'))" "${dirs[@]}"
['/a-1/b-1/c-1',
 '/a-1/b-2/c-1',
 '/a-1/b-2/some/garbage/c-1',
 '/a-1/b-2/some/more/garbage/c-1']

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions