Skip to content
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

Only use an absolute path in the activate script. #569

Merged
merged 1 commit into from
Jan 28, 2024
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
30 changes: 24 additions & 6 deletions script/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,22 @@ display_path() {
echo "$1"
fi
}
abspath() {
if [[ -d "$1" ]]
then
pushd "$1" >/dev/null
pwd
popd >/dev/null
elif [[ -e "$1" ]]
then
pushd "$(dirname "$1")" >/dev/null
echo "$(pwd)/$(basename "$1")"
popd >/dev/null
else
echo "$1" does not exist! >&2
return 127
fi
}

COMMAND=
COMPILER=dmd
Expand Down Expand Up @@ -1062,6 +1078,8 @@ binexec_for_dub_compiler() {
}

write_env_vars() {
ROOT_ABS="$(abspath "$ROOT")"

local -r binpath=$(binpath_for_compiler "$1")
case $1 in
dmd*)
Expand Down Expand Up @@ -1124,14 +1142,14 @@ write_env_vars() {
if [ -n "$libpath" ] ; then
echo "_OLD_D_LIBRARY_PATH=\"\${LIBRARY_PATH:-}\""
echo "_OLD_D_LD_LIBRARY_PATH=\"\${LD_LIBRARY_PATH:-}\""
echo "export LIBRARY_PATH=\"$ROOT/$1/$libpath\${LIBRARY_PATH:+:}\${LIBRARY_PATH:-}\""
echo "export LD_LIBRARY_PATH=\"$ROOT/$1/$libpath\${LD_LIBRARY_PATH:+:}\${LD_LIBRARY_PATH:-}\""
echo "export LIBRARY_PATH=\"$ROOT_ABS/$1/$libpath\${LIBRARY_PATH:+:}\${LIBRARY_PATH:-}\""
echo "export LD_LIBRARY_PATH=\"$ROOT_ABS/$1/$libpath\${LD_LIBRARY_PATH:+:}\${LD_LIBRARY_PATH:-}\""
fi

echo "_OLD_D_PATH=\"\${PATH:-}\""
echo "_OLD_D_PS1=\"\${PS1:-}\""
echo "export PS1=\"($1)\${PS1:-}\""
echo "export PATH=\"${DUB_BIN_PATH}${DUB_BIN_PATH:+:}$ROOT/$1/$binpath\${PATH:+:}\${PATH:-}\""
echo "export PATH=\"${DUB_BIN_PATH}${DUB_BIN_PATH:+:}$ROOT_ABS/$1/$binpath\${PATH:+:}\${PATH:-}\""

if [ -n "$dmd" ] ; then
echo "export DMD=$dmd"
Expand Down Expand Up @@ -1168,13 +1186,13 @@ write_env_vars() {
echo "set -g _OLD_D_PATH \$PATH"
echo "set -g _OLD_D_PS1 \$PS1"
echo
echo "set -gx PATH ${DUB_BIN_PATH:+\'}${DUB_BIN_PATH}${DUB_BIN_PATH:+\' }'$ROOT/$1/$binpath' \$PATH"
echo "set -gx PATH ${DUB_BIN_PATH:+\'}${DUB_BIN_PATH}${DUB_BIN_PATH:+\' }'$ROOT_ABS/$1/$binpath' \$PATH"

if [ -n "$libpath" ] ; then
echo "set -g _OLD_D_LIBRARY_PATH \$LIBRARY_PATH"
echo "set -g _OLD_D_LD_LIBRARY_PATH \$LD_LIBRARY_PATH"
echo "set -gx LIBRARY_PATH '$ROOT/$1/$libpath' \$LIBRARY_PATH"
echo "set -gx LD_LIBRARY_PATH '$ROOT/$1/$libpath' \$LD_LIBRARY_PATH"
echo "set -gx LIBRARY_PATH '$ROOT_ABS/$1/$libpath' \$LIBRARY_PATH"
echo "set -gx LD_LIBRARY_PATH '$ROOT_ABS/$1/$libpath' \$LD_LIBRARY_PATH"
fi

if [ -n "$dmd" ] ; then
Expand Down
Loading