From 7d256b203c881c92de7c79c018597953d7dcb162 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 14 Jul 2021 18:47:01 +0300 Subject: [PATCH] kiss: support a system-wide hook directory with easy use. Hooks installed to /var/db/kiss/hooks can be accessed via their basename. Usage is as follows. $ ls -1 /var/db/kiss/hooks no-docs shell-on-exit $ export KISS_HOOK=no-docs:shell-on-exit:/home/dylan/bin/kiss_hook See #229 --- kiss | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kiss b/kiss index 18c0a67..30e7aa3 100755 --- a/kiss +++ b/kiss @@ -120,9 +120,18 @@ run_hook() { unset IFS - for hook do "$hook" "$_type" "$_name" "$_path" || - die "$_name" "$_type hook failed: '$hook'" - done + for hook do case $hook in + */*) + # Absolute path to hook. + "$hook" "$_type" "$_name" "$_path" + ;; + + *) + # Hook in system-wide hook directory (/var/db/kiss/hooks). + # Hooks in this directory can be used via their basename. + "$sys_db/../hooks/$hook" "$_type" "$_name" "$_path" + ;; + esac || die "$_name" "$_type hook failed: '$hook'"; done } run_hook_pkg() {