I am trying to make this script work which was initially written by one of my coworkers for bash shells. The plan is to source it in the zsh shell. As far as I understand it, this script allows to access the helper scripts that are held in this dir across the terminal. However, when I execute just this bit, I keep getting the error message.
I have tried following solutions of some of the already answered questions such as substituting ${BASH_SOURCE[0]}
with ${(%):-%N
or ${(%):-%x}
From here.
PATHNAME="$_";
if [[ "$PATHNAME" != "$0" ]]; then
export EXAMPLE_DIR=$(dirname $(dirname $(realpath ${BASH_SOURCE[0]})));
else
>&2 echo "This script should be sourced, not executed in a subshell";
fi
I do not understand why do I keep getting the error and I would really like to understand what is the issue with it. Any help or links for reading extremely appreciated!