Skip to content

Commit

Permalink
Replace bash shell completion version error with warning (#2576)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism authored Aug 17, 2023
2 parents 22b9b1c + d9db70c commit a260ca6
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 a260ca6

Please sign in to comment.