1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-11 13:24:28 +01:00
nux-env/inc/nux/check.inc.sh
Tony Tkacik 59b79ea88e *: rewrite some files to nuxsh.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
2017-07-16 18:39:13 +02:00

31 lines
574 B
Bash

## nux.check.function:: <name>
##
function nux.check.function {
nux.log trace "Checking if $1 is function."
declare -f "$1" &>/dev/null && return 0
return 1
}
function nux.check.nuxenv.file {
path=$(realpath -Lms "$1")
[[ "$path" =~ "^$NUX_ENV_DIR" ]]
}
function nux.check.optional {
local function="$1"; shift;
if nux.check.function "$function" ; then
$function "$@"
fi
}
function nux.check.exec {
local binary=$1;
test -n "$(which "$binary")"
}
## nux.check.file.exists:: <name>
##
function nux.check.file.exists {
test -e "$1" -o -h "$1";
}