From: Matthias Kruk Date: Thu, 22 Dec 2022 04:38:06 +0000 (+0900) Subject: toolbox.sh: Don't mask realpath's return value X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=2d5b5d4fd765a7b3e3bb3f795fd75a226e2676e8;p=toolbox toolbox.sh: Don't mask realpath's return value When determining the location of toolbox.sh, the result from realpath is passed to dirname to remove the script name from the path. However, both commands are executed in the same statement, causing the return value of realpath to be masked by dirname. This commit splits the statement into separate steps, so that return values are not masked. --- diff --git a/toolbox.sh b/toolbox.sh index b234b8d..8df68ad 100644 --- a/toolbox.sh +++ b/toolbox.sh @@ -17,18 +17,21 @@ # along with this program. If not, see . __toolbox_init() { - local modpath + local toolboxpath + local toolboxroot - if ! modpath="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"; then + if ! toolboxpath=$(realpath "${BASH_SOURCE[0]}"); then echo "Could not determine toolbox path" 1>&2 return 1 fi - declare -gxr TOOLBOX_PATH="$modpath" + toolboxroot="${toolboxpath%/*}" + + declare -gxr TOOLBOX_PATH="$toolboxroot" declare -gxr TOOLBOX_HOME="$HOME/.toolbox" declare -axgr __TOOLBOX_MODULEPATH=( "$TOOLBOX_HOME/include" - "$modpath/include" + "$toolboxroot/include" ) declare -Axg __TOOLBOX_INCLUDED