Add load_module function to shell-functions
This commit is contained in:
parent
e0ab531085
commit
b80715ccea
1 changed files with 24 additions and 0 deletions
|
@ -22,3 +22,27 @@ function print_error_sub_noisy { [ ${NOISY:-0} -ge $1 ] && print_error_sub $@[2,
|
|||
|
||||
function binary_exists { return $(hash $1 1>/dev/null 2>&1) }
|
||||
function binary_not_exists { binary_exists $1; return $(( ! $? )) }
|
||||
|
||||
function load_module {
|
||||
local mod=$1
|
||||
|
||||
local modpath
|
||||
for p in $fpath; do
|
||||
modpath=$p/$1
|
||||
[[ -d $modpath ]] && break
|
||||
modpath=''
|
||||
done
|
||||
|
||||
if [[ -z "$modpath" ]]; then
|
||||
print_error "Couldn't find path to module: $mod"
|
||||
return 1
|
||||
fi
|
||||
|
||||
print_info "Loading module: $mod"
|
||||
for func in `ls $modpath`; do
|
||||
print_info_sub "Loading function: $func"
|
||||
autoload $func
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue