mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
*: rewrite some files to nuxsh.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
eef3628269
commit
59b79ea88e
7 changed files with 396 additions and 145 deletions
31
inc/nux/check.inc.sh
Normal file
31
inc/nux/check.inc.sh
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
## 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";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue