zapret/common/custom.sh
2024-10-12 12:33:06 +03:00

26 lines
432 B
Bash

custom_runner()
{
# $1 - function name
# $2+ - params
local n script FUNC=$1
shift
[ -f "$CUSTOM_DIR/custom" ] && {
unset -f $FUNC
. "$CUSTOM_DIR/custom"
existf $FUNC && $FUNC "$@"
}
[ -d "$CUSTOM_DIR/custom.d" ] && {
n=$(ls "$CUSTOM_DIR/custom.d" | wc -c | xargs)
[ "$n" = 0 ] || {
for script in "$CUSTOM_DIR/custom.d/"*; do
unset -f $FUNC
. "$script"
existf $FUNC && $FUNC "$@"
done
}
}
}