diff options
Diffstat (limited to 'src/click/utils.py')
-rw-r--r-- | src/click/utils.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/click/utils.py b/src/click/utils.py index 2525e98..467b7b6 100644 --- a/src/click/utils.py +++ b/src/click/utils.py @@ -1,4 +1,5 @@ import os +import re import sys import typing as t from functools import update_wrapper @@ -536,7 +537,7 @@ def _expand_args( See :func:`glob.glob`, :func:`os.path.expanduser`, and :func:`os.path.expandvars`. - This intended for use on Windows, where the shell does not do any + This is intended for use on Windows, where the shell does not do any expansion. It may not exactly match what a Unix shell would do. :param args: List of command line arguments to expand. @@ -544,6 +545,10 @@ def _expand_args( :param env: Expand environment variables. :param glob_recursive: ``**`` matches directories recursively. + .. versionchanged:: 8.1 + Invalid glob patterns are treated as empty expansions rather + than raising an error. + .. versionadded:: 8.0 :meta private: @@ -559,7 +564,10 @@ def _expand_args( if env: arg = os.path.expandvars(arg) - matches = glob(arg, recursive=glob_recursive) + try: + matches = glob(arg, recursive=glob_recursive) + except re.error: + matches = [] if not matches: out.append(arg) |