Skip to content

Commit

Permalink
bash version support shows warning instead of error
Browse files Browse the repository at this point in the history
  • Loading branch information
superatomic authored and davidism committed Aug 17, 2023
1 parent 22b9b1c commit d9db70c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions src/click/shell_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
Expand Down

0 comments on commit d9db70c

Please sign in to comment.