Skip to content

Commit e10d4b2

Browse files
jtreeslukaszsamson
andauthored
Make wrapper script more robust... more robustly (#473)
* Make wrapper script more robust... more robustly This makes a setup possible in which a symlink points to the file (e.g. /usr/local/bin/elixir-ls -> /opt/elixir-ls/language_server.sh). It's a rehash of a previous commit that was reverted since it broke setups where the language server was installed in a path containing spaces (e.g. /opt/Elixir Language Server/). This variant takes that possibility into account. * Avoid undefined behaviour in launch.sh I'm not really sure what could lead this to happen. Maybe some weird directory permissions with the read bit on and the exec bit off... Still good to be careful though. Co-authored-by: Łukasz Samson <[email protected]> Co-authored-by: Joshua Trees <[email protected]> Co-authored-by: Łukasz Samson <[email protected]>
1 parent 9aac258 commit e10d4b2

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

apps/elixir_ls_utils/priv/debugger.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
#!/bin/sh
22
# Launches the debugger. This script must be in the same directory as the compiled .ez archives.
33

4+
readlink_f () {
5+
cd "$(dirname "$1")" > /dev/null || exit 1
6+
filename="$(basename "$1")"
7+
if [ -h "$filename" ]; then
8+
readlink_f "$(readlink "$filename")"
9+
else
10+
echo "$(pwd -P)/$filename"
11+
fi
12+
}
13+
414
if [ -z "${ELS_INSTALL_PREFIX}" ]; then
5-
dir=$(dirname "$0")
15+
dir="$(dirname "$(readlink_f "$0")")"
616
else
717
dir=${ELS_INSTALL_PREFIX}
818
fi

apps/elixir_ls_utils/priv/language_server.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
#!/bin/sh
22
# Launches the language server. This script must be in the same directory as the compiled .ez archives.
33

4+
readlink_f () {
5+
cd "$(dirname "$1")" > /dev/null || exit 1
6+
filename="$(basename "$1")"
7+
if [ -h "$filename" ]; then
8+
readlink_f "$(readlink "$filename")"
9+
else
10+
echo "$(pwd -P)/$filename"
11+
fi
12+
}
13+
414
if [ -z "${ELS_INSTALL_PREFIX}" ]; then
5-
dir=$(dirname "$0")
15+
dir="$(dirname "$(readlink_f "$0")")"
616
else
717
dir=${ELS_INSTALL_PREFIX}
818
fi

apps/elixir_ls_utils/priv/launch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fi
5252
# include the local .ez files, and then do what we were asked to do.
5353

5454
readlink_f () {
55-
cd "$(dirname "$1")" > /dev/null
55+
cd "$(dirname "$1")" > /dev/null || exit 1
5656
filename="$(basename "$1")"
5757
if [ -h "$filename" ]; then
5858
readlink_f "$(readlink "$filename")"

0 commit comments

Comments
 (0)