@@ -27,7 +27,7 @@ basalt.package-init() {
2727local __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 ]} "
3131if [ -L " $__basalt_file " ]; then
3232local __basalt_target=
3333__basalt_target=$( readlink " $__basalt_file " )
@@ -42,20 +42,16 @@ basalt.package-init() {
4242fi
4343fi
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+
4551if ! cd " $__old_cd " ; then
4652printf ' %s\n' " Error: basalt: Could not cd back to '$__old_cd '" >&2
4753exit 1
4854fi
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
5955fi
6056}
6157
0 commit comments