mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Warn about incompatible Bash version for the Shell Completion // Resolve #4326
This commit is contained in:
@ -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>`_)
|
* 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 `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
|
* 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>`__ 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 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>`__
|
* 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>`__
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@ -26,6 +28,14 @@ class ShellType(Enum):
|
|||||||
BASH = "bash"
|
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):
|
def get_completion_install_path(shell):
|
||||||
home_dir = os.path.expanduser("~")
|
home_dir = os.path.expanduser("~")
|
||||||
prog_name = click.get_current_context().find_root().info_name
|
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):
|
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):
|
if is_completion_code_installed(shell, path):
|
||||||
return None
|
return None
|
||||||
append = shell != ShellType.FISH
|
append = shell != ShellType.FISH
|
||||||
|
Reference in New Issue
Block a user