Chore: Do not execute any code when forgit is sourced (#464)

In order to run unit tests for individual functions we have to be able
to source the script without triggering the main execution flow.
This commit is contained in:
carlfriedrich 2025-09-06 13:25:23 +02:00
parent 9b3b185e24
commit ab6a63ee0f

View file

@ -1270,4 +1270,10 @@ PRIVATE_COMMANDS=(
"pager"
)
# Check if the script is being sourced. This is necessary for unit tests where
# we do not want to execute the main function.
if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then
return 0
fi
main "${@}"