diff --git a/sharness.sh b/sharness.sh index 71e93426e..b6f2f08c7 100644 --- a/sharness.sh +++ b/sharness.sh @@ -20,10 +20,7 @@ if test -n "${ZSH_VERSION-}" then - emulate sh - ARGZERO="$ZSH_ARGZERO" -else - ARGZERO="$0" + emulate sh -o POSIX_ARGZERO fi # Public: Current version of Sharness. @@ -34,7 +31,7 @@ export SHARNESS_VERSION # Public: The file extension for tests. By default, it is set to "t". export SHARNESS_TEST_EXTENSION -: "${SHARNESS_TEST_DIRECTORY:=$(dirname "$ARGZERO")}" +: "${SHARNESS_TEST_DIRECTORY:=$(dirname "$0")}" # ensure that SHARNESS_TEST_DIRECTORY is an absolute path so that it # is valid even if the current working directory is changed SHARNESS_TEST_DIRECTORY=$(cd "$SHARNESS_TEST_DIRECTORY" && pwd) || exit 1 @@ -73,7 +70,7 @@ done,*) ;; *' --tee '*|*' --verbose-log '*) mkdir -p "$SHARNESS_TEST_OUTDIR/test-results" - BASE="$SHARNESS_TEST_OUTDIR/test-results/$(basename "$ARGZERO" ".$SHARNESS_TEST_EXTENSION")" + BASE="$SHARNESS_TEST_OUTDIR/test-results/$(basename "$0" ".$SHARNESS_TEST_EXTENSION")" # Make this filename available to the sub-process in case it is using # --verbose-log. @@ -84,7 +81,7 @@ done,*) # from any previous runs. : >"$SHARNESS_TEST_TEE_OUTPUT_FILE" - (SHARNESS_TEST_TEE_STARTED="done" ${SHELL_PATH} "$ARGZERO" "$@" 2>&1; + (SHARNESS_TEST_TEE_STARTED="done" ${SHELL_PATH} "$0" "$@" 2>&1; echo $? >"$BASE.exit") | tee -a "$SHARNESS_TEST_TEE_OUTPUT_FILE" test "$(cat "$BASE.exit")" = 0 exit @@ -671,7 +668,7 @@ PATH="$SHARNESS_BUILD_DIRECTORY:$PATH" export PATH # Public: Path to test script currently executed. -SHARNESS_TEST_FILE="$ARGZERO" +SHARNESS_TEST_FILE="$0" export SHARNESS_TEST_FILE # Prepare test area.