Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Unreleased
:issue:`2632`
- Fix ``click.echo(color=...)`` passing ``color`` to coloroma so it can be
forced on Windows. :issue:`2606`.

- More robust bash version check, fixing problem on Windows with git-bash.
:issue:`2638`

Version 8.1.7
-------------
Expand Down
15 changes: 11 additions & 4 deletions src/click/shell_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,19 @@ class BashComplete(ShellComplete):

@staticmethod
def _check_version() -> None:
import shutil
import subprocess

output = subprocess.run(
["bash", "-c", 'echo "${BASH_VERSION}"'], stdout=subprocess.PIPE
)
match = re.search(r"^(\d+)\.(\d+)\.\d+", output.stdout.decode())
bash_exe = shutil.which("bash")

if bash_exe is None:
match = None
else:
output = subprocess.run(
[bash_exe, "--norc", "-c", 'echo "${BASH_VERSION}"'],
stdout=subprocess.PIPE,
)
match = re.search(r"^(\d+)\.(\d+)\.\d+", output.stdout.decode())

if match is not None:
major, minor = match.groups()
Expand Down