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

36 lines
635 B
Bash

## nux.check.function:: <name>
##
function nux.check.function {
nux.log trace "Checking if $1 is function."
test "$(type -t "$1")" = "function" && 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";
}
function nux.check.file.symlink {
test -h "$1";
}