Fix 'set -e' and others get lost when sourcing 'bin/include/versioning'
#!/bin/bash
-set +o errexit +o nounset
-
-test -n "${XTRACE}" && set -o xtrace
-
+old_options="$(set +o); set -$-"
set -o errexit -o nounset
+if [ -n "${XTRACE:-}" ] ; then
+ set -o xtrace
+fi
+
GIT_ROOT=${GIT_ROOT:-$(git rev-parse --show-toplevel)}
GIT_DESCRIBE=$(git describe --tags --long || (git tag -a v0.0.0 -m "tag v0.0.0"; git describe --tags --long))
GIT_BRANCH=${GIT_BRANCH:-$(git name-rev --name-only HEAD)}
@@ -17,4 +18,6 @@ GIT_TAG=$(echo "${GIT_DESCRIBE}" | awk -F - '{ print $1 }')
ARTIFACT_VERSION="${GIT_TAG}-${GIT_COMMITS}.${GIT_SHA}"
-set +o errexit +o nounset +o xtrace
+# Restore shell options (in case this script is being sourced)
+set +x;
+eval "$old_options"
\ No newline at end of file
