diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2013-05-21 11:59:21 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2013-05-22 00:05:19 +0200 |
commit | a422365b7cbd5cdaa8e3f36e14d5480c22f8cb6f (patch) | |
tree | f21a93f329545248743ea1d7f561f6060b531a4b /t/ax | |
parent | ffd4ecc946c6b150f5ee5684fa04bd4f9e8b7af9 (diff) | |
download | automake-a422365b7cbd5cdaa8e3f36e14d5480c22f8cb6f.tar.gz |
tests: only activate 'unset' alias if required
This makes the test logs easier to read for most shells (which do not
actually require that alias). This is especially important now that
'unset' is used in the new 'run_make()' function, and that function is
likely going to be used more and more in the future.
* t/ax/test-lib.sh (_am_unset, unset): Only define this function and
alias if "unset VAR" returns a non-zero exit status when VAR is already
unset.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't/ax')
-rw-r--r-- | t/ax/test-lib.sh | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/t/ax/test-lib.sh b/t/ax/test-lib.sh index ee83dcff3..aa015d68d 100644 --- a/t/ax/test-lib.sh +++ b/t/ax/test-lib.sh @@ -105,18 +105,24 @@ alias exit=_am_exit # "unset VAR" returns a non-zero exit status in case the VAR variable # is already unset. This doesn't interact well with our usage of # "set -e" in the testsuite. This function and the alias below help -# to work around the issue. -_am_unset () -{ - for _am_v - do - # Extra escaping (here and below) to ensure we do not call our - # 'unset' alias. - eval ${_am_v}=dummy && \unset ${_am_v} || exit 1 - done - \unset _am_v -} -alias unset=_am_unset +# to work around the issue. But be sure to use them only if actually +# needed. The repeated unset in the check below cater to the very +# unlikely case where the '_am_v' variable is set in the environment. +if unset _am_v && unset _am_v; then + : Nothing needs to be done. +else + _am_unset () + { + for _am_v + do + # Extra escaping (here and below) to ensure we do not call our + # 'unset' alias. + eval ${_am_v}=dummy && \unset ${_am_v} || return 1 + done + \unset _am_v + } + alias unset=_am_unset +fi ## ------------------------------------ ## ## General testsuite shell functions. ## |