Obrigado @grawity, eu escrevi isto:
# Call the main function, as when running from the command line the '$0' variable is
# not empty.
#
# Importing functions from a shell script
# https://stackoverflow.com/questions/12815774/importing-functions-from-a-shell-script
if ! [[ -z "$0" ]]
then
# Reliable way for a bash script to get the full path to itself?
# http://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get
pushd 'dirname $0' > /dev/null
SCRIPT_FOLDER_PATH='pwd'
popd > /dev/null
if[[ "$SCRIPT_FOLDER_PATH" == "$(pwd)" || "$SCRIPT_FOLDER_PATH" == "$(dirname "$0")" ]]
then
main "$@"
else
printf "You cannot run this from the folder: \n'$(pwd)'\n"
printf "\nPlease, run this script from its folder on: \n'$SCRIPT_FOLDER_PATH'\n"
fi
fi