Skip to content

Recursive '**' matches non-existent directories. #79382

Closed

Description

@daniel
mannequin
BPO 35201
Nosy @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2018-11-09.16:54:51.725>
labels = ['type-bug', 'library', '3.9', '3.10', '3.11']
title = "Recursive '**' matches non-existent directories."
updated_at = <Date 2021-12-01.22:35:42.687>
user = 'https://bugs.python.org/daniel'

bugs.python.org fields:

activity = <Date 2021-12-01.22:35:42.687>
actor = 'iritkatriel'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2018-11-09.16:54:51.725>
creator = 'daniel'
dependencies = []
files = []
hgrepos = []
issue_num = 35201
keywords = []
message_count = 3.0
messages = ['329537', '329539', '329703']
nosy_count = 2.0
nosy_names = ['serhiy.storchaka', 'daniel']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue35201'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

Linked PRs

Activity

  1. daniel commented on Nov 9, 2018

    danielmannequin
    MannequinAuthor

    In the following case, when there is no file or directory 'a', glob will still return it:

    >>> glob.glob("a/**", recursive=True)
    [ 'a/' ]

    Note that this is inconsistent with the '*' pattern:

    >>> glob.glob("a/*", recursive=True)
    []
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-bugAn unexpected behavior, bug, or error
    on Nov 9, 2018
  3. serhiy-storchaka commented on Nov 9, 2018

    @serhiy-storchaka
    Member

    This is expected behavior, and it matches the behavior of Bash.

    $ mkdir empty
    $ shopt -s globstar failglob
    $ echo empty/*
    bash: no match: empty/*
    $ echo empty/**
    empty/

    "**" matches zero or more path components. In this case case it matches zero.

  4. daniel commented on Nov 12, 2018

    danielmannequin
    MannequinAuthor

    In the Bash example, you created the directory empty/. This bug is specifically when the directory in question does not exist.

  5. transferred this issue fromon Apr 10, 2022
  6. LuckyDams commented on May 24, 2022

    @LuckyDams

    Similar issue with existing file returned as directory:

    $ touch file
    $ shopt -s globstar failglob
    $ echo file/*
    -bash: no match: file/*
    $ echo file/**
    -bash: no match: file/**
    >>> glob.glob('file/*', recursive=True)
    []
    
    >>> glob.glob('file/**', recursive=True)
    ['file/']
  7. added 2 commits that reference this issue on Feb 7, 2024
  8. added 2 commits that reference this issue on Feb 11, 2024
  9. added 2 commits that reference this issue on Feb 11, 2024
  10. added a commit that references this issue on Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

3.10 (EOL)end of life3.11only security fixes3.12only security fixes3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions