Skip to content

Commit de20008

Browse files
committed
fix: Find binary file to execute
1 parent 4953fda commit de20008

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

pkg/share/scripts/basalt-package-init.sh

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ basalt.package-init() {
2727
local __old_cd="$PWD"
2828

2929
# Do not use "$0", since it won't work in some environments, such as Bats
30-
local __basalt_file="${BASH_SOURCE[0]}"
30+
local __basalt_file="${BASH_SOURCE[1]}"
3131
if [ -L "$__basalt_file" ]; then
3232
local __basalt_target=
3333
__basalt_target=$(readlink "$__basalt_file")
@@ -42,20 +42,16 @@ basalt.package-init() {
4242
fi
4343
fi
4444

45+
init.get_basalt_package_dir
46+
# Note that this variable should not be exported. It can cause weird things to occur. For example,
47+
# if a Basalt local package called a command from a global package, things won't work since
48+
# 'BASALT_PACKAGE_DIR' would already be defined and won't be properly set for the global package
49+
BASALT_PACKAGE_DIR=$REPLY
50+
4551
if ! cd "$__old_cd"; then
4652
printf '%s\n' "Error: basalt: Could not cd back to '$__old_cd'" >&2
4753
exit 1
4854
fi
49-
50-
# TODO: is this needed here
51-
if [ -z "$BASALT_PACKAGE_DIR" ]; then
52-
init.get_basalt_package_dir
53-
54-
# Note that this variable should not be exported. It can cause weird things to occur. For example,
55-
# if a Basalt local package called a command from a global package, things won't work since
56-
# 'BASALT_PACKAGE_DIR' would already be defined and won't be properly set for the global package
57-
BASALT_PACKAGE_DIR=$REPLY
58-
fi
5955
fi
6056
}
6157

0 commit comments

Comments
 (0)