fix error from basename when using source to run hack/lib/init.sh
The example in CONTRIBUTING.adoc uses 'source' to run hack/lib/init.sh and
prints an error on an invalid basename command due to $0 returning "-bash".
@@ -51,7 +51,12 @@ os::log::stacktrace::install
os::util::environment::update_path_var
if [[ -z "${OS_TMP_ENV_SET-}" ]]; then
- os::util::environment::setup_tmpdir_vars "$( basename "$0" ".sh" )"
+ # if this file is run via 'source', then $0 will be "-bash" and won't work with basename
+ if [[ "${0}" =~ .*\.sh ]]; then
+ os::util::environment::setup_tmpdir_vars "$( basename "${0}" ".sh" )"
+ else
+ os::util::environment::setup_tmpdir_vars "shell"
+ fi
fi
# Allow setting $JUNIT_REPORT to toggle output behavior
