Skip to content

Commit 0b97b92

Browse files
authored
Merge pull request #717 from babaric-dev/completionsrc
Add fallback mechanism if `pkg-config` fails
2 parents c5ae572 + 6750ad6 commit 0b97b92

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

Diff for: server/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Bash Language Server
22

3+
## 4.7.0
4+
5+
- 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
6+
37
## 4.6.2
48

59
- 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 for: server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "A language server for Bash",
44
"author": "Mads Hartmann",
55
"license": "MIT",
6-
"version": "4.6.2",
6+
"version": "4.7.0",
77
"main": "./out/server.js",
88
"typings": "./out/server.d.ts",
99
"bin": {

Diff for: server/src/get-options.sh

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
#!/usr/bin/env bash
22

3+
# Try and get COMPLETIONSRC using pkg-config
34
COMPLETIONSDIR="$(pkg-config --variable=completionsdir bash-completion)"
4-
DATADIR="$(dirname "$(dirname "${COMPLETIONSDIR}")")"
55

6-
# Exit if bash-completion isn't installed.
7-
if (( $? != 0 ))
6+
if (( $? == 0 ))
7+
then
8+
COMPLETIONSRC="$(dirname "$COMPLETIONSDIR")/bash_completion"
9+
else
10+
# Fallback if pkg-config fails
11+
if [ "$(uname -s)" = "Darwin" ]
12+
then
13+
# Running macOS
14+
COMPLETIONSRC="$(brew --prefix)/etc/bash_completion"
15+
else
16+
# Suppose running Linux
17+
COMPLETIONSRC="${PREFIX:-/usr}/share/bash-completion/bash_completion"
18+
fi
19+
fi
20+
21+
# Validate path of COMPLETIONSRC
22+
if (( $? != 0 )) || [ ! -r "$COMPLETIONSRC" ]
823
then
924
exit 1
1025
fi
1126

12-
source "$DATADIR/bash-completion/bash_completion"
27+
source "$COMPLETIONSRC"
1328

1429
COMP_LINE="$*"
1530
COMP_WORDS=("$@")

0 commit comments

Comments
 (0)