Warn about incompatible Bash version for the Shell Completion // Resolve #4326

This commit is contained in:
Ivan Kravets
2022-06-20 22:40:36 +03:00
parent 92a5c1bac6
commit 092326cb91
2 changed files with 13 additions and 0 deletions

View File

@ -35,6 +35,7 @@ PlatformIO Core 6
* Allowed to ``Import("projenv")`` in a library extra script (`issue #4305 <https://github.com/platformio/platformio-core/issues/4305>`_)
* Improved a serial port finder for `Black Magic Probe <https://docs.platformio.org/en/latest/plus/debug-tools/blackmagic.html>`__ (`issue #4023 <https://github.com/platformio/platformio-core/issues/4023>`_)
* Improved a serial port finder for a board with predefined HWIDs
* Warn about incompatible Bash version for the `Shell Completion <https://docs.platformio.org/en/latest/core/userguide/system/completion/index.html>`__ (`issue #4326 <https://github.com/platformio/platformio-core/issues/4326>`_)
* Fixed an issue when the `build_unflags <https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-unflags>`__ operation ignores a flag value (`issue #4309 <https://github.com/platformio/platformio-core/issues/4309>`_)
* Fixed an issue when the `build_unflags <https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-unflags>`__ option was not applied to the ``ASPPFLAGS`` scope
* Fixed an issue on Windows OS when flags were wrapped to the temporary file while generating the `Compilation database "compile_commands.json" <https://docs.platformio.org/en/latest/integration/compile_commands.html>`__

View File

@ -13,6 +13,8 @@
# limitations under the License.
import os
import re
import subprocess
from enum import Enum
import click
@ -26,6 +28,14 @@ class ShellType(Enum):
BASH = "bash"
def get_bash_version():
result = subprocess.run(["bash", "--version"], capture_output=True, check=True)
match = re.search(r"version\s+(\d+)\.(\d+)", result.stdout.decode())
if match:
return (int(match.group(1)), int(match.group(2)))
return (0, 0)
def get_completion_install_path(shell):
home_dir = os.path.expanduser("~")
prog_name = click.get_current_context().find_root().info_name
@ -59,6 +69,8 @@ def is_completion_code_installed(shell, path):
def install_completion_code(shell, path):
if shell == ShellType.BASH and get_bash_version() < (4, 4):
raise click.ClickException("The minimal supported Bash version is 4.4")
if is_completion_code_installed(shell, path):
return None
append = shell != ShellType.FISH