From 1874c0de0008aae88b01b14c4bc89f5ec5cb5e34 Mon Sep 17 00:00:00 2001 From: babaric-dev <104625126+babaric-dev@users.noreply.github.com> Date: Tue, 7 Feb 2023 22:12:32 +0800 Subject: [PATCH 1/2] Add fallback mechanism if `pkg-config` fails `COMPLETIONSRC`: path to sourced `bash_completion` If `pkg-config` fails to get `bash_completion` script: - use `brew` on macOS - use `PREFIX` on Linux --- server/src/get-options.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/server/src/get-options.sh b/server/src/get-options.sh index 0bb6a005d..470e43383 100755 --- a/server/src/get-options.sh +++ b/server/src/get-options.sh @@ -1,15 +1,30 @@ #!/usr/bin/env bash +# Try and get COMPLETIONSRC using pkg-config COMPLETIONSDIR="$(pkg-config --variable=completionsdir bash-completion)" -DATADIR="$(dirname "$(dirname "${COMPLETIONSDIR}")")" -# Exit if bash-completion isn't installed. -if (( $? != 0 )) +if (( $? == 0 )) +then + COMPLETIONSRC="$(dirname "$COMPLETIONSDIR")/bash_completion" +else + # Fallback if pkg-config fails + if [ "$(uname -s)" = "Darwin" ] + then + # Running macOS + COMPLETIONSRC="$(brew --prefix)/etc/bash_completion" + else + # Suppose running Linux + COMPLETIONSRC="${PREFIX:-/usr}/share/bash-completion/bash_completion" + fi +fi + +# Validate path of COMPLETIONSRC +if (( $? != 0 )) || [ ! -r "$COMPLETIONSRC" ] then exit 1 fi -source "$DATADIR/bash-completion/bash_completion" +source "$COMPLETIONSRC" COMP_LINE="$*" COMP_WORDS=("$@") From 6750ad6a6c7e253c696ce646ce15cc1c53ed728c Mon Sep 17 00:00:00 2001 From: Kenneth Skovhus Date: Thu, 9 Feb 2023 09:37:04 +0100 Subject: [PATCH 2/2] Bump server version to 4.7.0 --- server/CHANGELOG.md | 4 ++++ server/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/CHANGELOG.md b/server/CHANGELOG.md index 87e0954c0..52fb404c8 100644 --- a/server/CHANGELOG.md +++ b/server/CHANGELOG.md @@ -1,5 +1,9 @@ # Bash Language Server +## 4.7.0 + +- Support for bash options auto completions when using Brew or when `pkg-config` fails, but bash completions are found in `"${PREFIX:-/usr}/share/bash-completion/bash_completion"` https://github.com/bash-lsp/bash-language-server/pull/717 + ## 4.6.2 - Remove diagnostics for missing nodes that turns out to be unstable (this was introduced in 4.5.3) https://github.com/bash-lsp/bash-language-server/pull/708 diff --git a/server/package.json b/server/package.json index f369bbdf5..ee90a4bb6 100644 --- a/server/package.json +++ b/server/package.json @@ -3,7 +3,7 @@ "description": "A language server for Bash", "author": "Mads Hartmann", "license": "MIT", - "version": "4.6.2", + "version": "4.7.0", "main": "./out/server.js", "typings": "./out/server.d.ts", "bin": {