Skip to content

Add fallback mechanism if pkg-config fails #717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -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": {
23 changes: 19 additions & 4 deletions server/src/get-options.sh
Original file line number Diff line number Diff line change
@@ -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=("$@")