Skip to content

Commit 730400c

Browse files
committed
run.sh: Resolve target_assembly to an absolute path
1 parent 7b69019 commit 730400c

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

assets/nix/run.sh

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,23 @@ arch=""
8888
executable_path=""
8989
lib_extension=""
9090

91+
abs_path() {
92+
# Resolve relative path to absolute from BASEDIR
93+
if [ "$1" = "${1#/}" ]; then
94+
set -- "${BASEDIR}/${1}"
95+
fi
96+
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
97+
}
98+
9199
# Set executable path and the extension to use for the libdoorstop shared object
92100
os_type="$(uname -s)"
93101
case ${os_type} in
94102
Linux*)
95-
executable_path="${executable_name}"
96-
# Handle relative paths
97-
if [ "$executable_path" = "${executable_path#/}" ]; then
98-
executable_path="${BASEDIR}/${executable_path}"
99-
fi
103+
executable_path="$(abs_path "$executable_name")"
100104
lib_extension="so"
101105
;;
102106
Darwin*)
103-
real_executable_name="${executable_name}"
104-
105-
# Handle relative directories
106-
if [ "$real_executable_name" = "${real_executable_name#/}" ]; then
107-
real_executable_name="${BASEDIR}/${real_executable_name}"
108-
fi
107+
real_executable_name="$(abs_path "$executable_name")"
109108

110109
# If we're not even an actual executable, check .app Info for actual executable
111110
case $real_executable_name in
@@ -131,10 +130,6 @@ case ${os_type} in
131130
;;
132131
esac
133132

134-
abs_path() {
135-
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
136-
}
137-
138133
_readlink() {
139134
# relative links with readlink (without -f) do not preserve the path info
140135
ab_path="$(abs_path "$1")"
@@ -255,6 +250,8 @@ while [ $i -lt $max ]; do
255250
i=$((i+1))
256251
done
257252

253+
target_assembly="$(abs_path "$target_assembly")"
254+
258255
# Move variables to environment
259256
export DOORSTOP_ENABLED="$enabled"
260257
export DOORSTOP_TARGET_ASSEMBLY="$target_assembly"

0 commit comments

Comments
 (0)