Merge "Move back isset to the functions-common"
This commit is contained in:
commit
d7c874bca6
@ -62,6 +62,9 @@ function trueorfalse {
|
||||
$xtrace
|
||||
}
|
||||
|
||||
function isset {
|
||||
[[ -v "$1" ]]
|
||||
}
|
||||
|
||||
# Control Functions
|
||||
# =================
|
||||
|
@ -205,16 +205,6 @@ function iniuncomment {
|
||||
$xtrace
|
||||
}
|
||||
|
||||
function isset {
|
||||
nounset=$(set +o | grep nounset)
|
||||
set +o nounset
|
||||
[[ -n "${!1+x}" ]]
|
||||
result=$?
|
||||
$nounset
|
||||
return $result
|
||||
}
|
||||
|
||||
|
||||
# Restore xtrace
|
||||
$INC_CONF_TRACE
|
||||
|
||||
|
@ -196,3 +196,20 @@ if is_ubuntu; then
|
||||
echo "is_package_installed() on deleted package failed"
|
||||
fi
|
||||
fi
|
||||
|
||||
# test isset function
|
||||
echo "Testing isset()"
|
||||
you_should_not_have_this_variable=42
|
||||
|
||||
if isset "you_should_not_have_this_variable"; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "\"you_should_not_have_this_variable\" not declared. failed"
|
||||
fi
|
||||
|
||||
unset you_should_not_have_this_variable
|
||||
if isset "you_should_not_have_this_variable"; then
|
||||
echo "\"you_should_not_have_this_variable\" looks like declared variable. failed"
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user