Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace bash shell completion version error with warning #2576

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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