zapret/common/custom.sh

26 lines
432 B
Bash
Raw Normal View History

2024-10-28 11:32:24 +05:00
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
}
}
}