[zsh] Update the load_module function -- it's old and crusty
This commit is contained in:
parent
bb3fd71ddb
commit
8eebcd73de
1 changed files with 13 additions and 5 deletions
|
@ -4,7 +4,12 @@
|
||||||
function load_module
|
function load_module
|
||||||
{
|
{
|
||||||
local mod=$1
|
local mod=$1
|
||||||
|
if [[ -z "$mod" ]]; then
|
||||||
|
print "Missing argument: path to module to load." >&2
|
||||||
|
return -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make sure $mod isn't already in $fpath
|
||||||
local modpath
|
local modpath
|
||||||
for p in $fpath; do
|
for p in $fpath; do
|
||||||
modpath=$p/$mod
|
modpath=$p/$mod
|
||||||
|
@ -13,16 +18,19 @@ function load_module
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "$modpath" ]]; then
|
if [[ -z "$modpath" ]]; then
|
||||||
ShellLog -l error "Couldn't find path to module: $mod"
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fpath+=($modpath)
|
fpath+=($modpath)
|
||||||
|
|
||||||
ShellLog "Loading module: $mod"
|
for file in $modpath/*; do
|
||||||
for func in `ls $modpath`; do
|
if [[ -f "$file" ]]; then
|
||||||
ShellLog "Loading function: $func"
|
autoload $func
|
||||||
autoload $func
|
fi
|
||||||
|
|
||||||
|
if [[ -d "$file" ]]; then
|
||||||
|
load_module "$file"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue