diff --git a/CHANGES.rst b/CHANGES.rst index 35a0ff428..3662e5696 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,7 @@ Version 8.1.7 Unreleased - Fix issue with regex flags in shell completion. :issue:`2581` +- Bash version detection issues a warning instead of an error. :issue:`2574` Version 8.1.6 diff --git a/src/click/shell_completion.py b/src/click/shell_completion.py index 9091f787e..af4a57a23 100644 --- a/src/click/shell_completion.py +++ b/src/click/shell_completion.py @@ -301,7 +301,8 @@ class BashComplete(ShellComplete): name = "bash" source_template = _SOURCE_BASH - def _check_version(self) -> None: + @staticmethod + def _check_version() -> None: import subprocess output = subprocess.run( @@ -313,15 +314,17 @@ def _check_version(self) -> None: major, minor = match.groups() if major < "4" or major == "4" and minor < "4": - raise RuntimeError( + echo( _( "Shell completion is not supported for Bash" " versions older than 4.4." - ) + ), + err=True, ) else: - raise RuntimeError( - _("Couldn't detect Bash version, shell completion is not supported.") + echo( + _("Couldn't detect Bash version, shell completion is not supported."), + err=True, ) def source(self) -> str: