MCPcopy
hub / github.com/pallets/click / _check_version

Method _check_version

src/click/shell_completion.py:334–364  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

332
333 @staticmethod
334 def _check_version() -> None:
335 import shutil
336 import subprocess
337
338 bash_exe = shutil.which("bash")
339
340 if bash_exe is None:
341 match = None
342 else:
343 output = subprocess.run(
344 [bash_exe, "--norc", "-c", 'echo "${BASH_VERSION}"'],
345 stdout=subprocess.PIPE,
346 )
347 match = re.search(r"^(\d+)\.(\d+)\.\d+", output.stdout.decode())
348
349 if match is not None:
350 major, minor = match.groups()
351
352 if major < "4" or major == "4" and minor < "4":
353 echo(
354 _(
355 "Shell completion is not supported for Bash"
356 " versions older than 4.4."
357 ),
358 err=True,
359 )
360 else:
361 echo(
362 _("Couldn't detect Bash version, shell completion is not supported."),
363 err=True,
364 )
365
366 def source(self) -> str:
367 self._check_version()

Callers 1

sourceMethod · 0.95

Calls 1

echoFunction · 0.70

Tested by

no test coverage detected