Archived
1
0

Trim LD_LIBRARY_PATH on startup

This commit is contained in:
Anmol Sethi
2020-05-28 00:49:37 -04:00
parent 9a3b9fcac2
commit 7ab47b3d83
2 changed files with 27 additions and 8 deletions

View File

@ -5,21 +5,22 @@
# More complicated than readlink -f or realpath to support macOS.
# See https://github.com/cdr/code-server/issues/1537
bin_dir() {
root_dir() {
# We read the symlink, which may be relative from $0.
dst="$(readlink "$0")"
# We cd into the $0 directory.
cd "$(dirname "$0")" || exit 1
# Now we can cd into the dst directory.
cd "$(dirname "$dst")" || exit 1
# Finally we use pwd -P to print the absolute path of the directory of $dst.
# Now we can cd into the directory above the dst directory which is the root
# of the release.
cd "$(dirname "$dst")/.." || exit 1
# Finally we use pwd -P to print the absolute path the root.
pwd -P || exit 1
}
BIN_DIR=$(bin_dir)
ROOT="$(root_dir)"
if [ "$(uname)" = "Linux" ]; then
export LD_LIBRARY_PATH="$BIN_DIR/../lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH="$ROOT/lib:$LD_LIBRARY_PATH"
elif [ "$(uname)" = "Darwin" ]; then
export DYLD_LIBRARY_PATH="$BIN_DIR/../lib${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}"
export DYLD_LIBRARY_PATH="$ROOT/lib:$DYLD_LIBRARY_PATH"
fi
exec "$BIN_DIR/../lib/node" "$BIN_DIR/.." "$@"
exec "$ROOT/lib/node" "$ROOT" "$@"