setup.sh: avoid subshells: type -t in _callImplicitHook
This commit is contained in:
parent
d53920a5be
commit
cf4e4820f6
|
@ -73,21 +73,18 @@ _callImplicitHook() {
|
||||||
set -u
|
set -u
|
||||||
local def="$1"
|
local def="$1"
|
||||||
local hookName="$2"
|
local hookName="$2"
|
||||||
case "$(type -t "$hookName")" in
|
if declare -F "$hookName" > /dev/null; then
|
||||||
(function|alias|builtin)
|
|
||||||
set +u
|
set +u
|
||||||
"$hookName";;
|
"$hookName"
|
||||||
(file)
|
elif type -p "$hookName" > /dev/null; then
|
||||||
set +u
|
set +u
|
||||||
source "$hookName";;
|
source "$hookName"
|
||||||
(keyword) :;;
|
elif [ -n "${!hookName:-}" ]; then
|
||||||
(*) if [ -z "${!hookName:-}" ]; then
|
|
||||||
return "$def";
|
|
||||||
else
|
|
||||||
set +u
|
set +u
|
||||||
eval "${!hookName}"
|
eval "${!hookName}"
|
||||||
fi;;
|
else
|
||||||
esac
|
return "$def"
|
||||||
|
fi
|
||||||
# `_eval` expects hook to need nounset disable and leave it
|
# `_eval` expects hook to need nounset disable and leave it
|
||||||
# disabled anyways, so Ok to to delegate. The alternative of a
|
# disabled anyways, so Ok to to delegate. The alternative of a
|
||||||
# return trap is no good because it would affect nested returns.
|
# return trap is no good because it would affect nested returns.
|
||||||
|
|
Loading…
Reference in New Issue