diff options
author | merakor <cem@ckyln.com> | 2021-11-03 12:45:33 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-11-03 12:45:33 +0000 |
commit | 3288d9f38b35e02b75d74d3fc55fe6e405879348 (patch) | |
tree | 76ca103d0608aee0fe2c9de9cfbcdabbefc50f74 | |
parent | 9bf3411e3477a062842f3a3fb0758882ee6d53ec (diff) | |
download | cpt-3288d9f38b35e02b75d74d3fc55fe6e405879348.tar.gz |
run_hook: fix logging, simplify
FossilOrigin-Name: 4b091264bec032884deb45237731351d8f3307b6546f3be08da751d8f9110bbd
-rw-r--r-- | src/cpt-lib.in | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in index effb730..517f198 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -555,25 +555,26 @@ pop() { } run_hook() { - # Run hooks defined by the system and the user. - - if [ "$2" ]; then - logv "$2" "Running $1 hook" - else - logv "Running $1 hook" - fi - - # Run all the hooks found in the configuration directory. + # Check that hooks exist before announcing that we are running a hook. set +f - for hook in "$cpt_confdir/hooks/"*; do + for hook in "$cpt_confdir/hooks/"* "$CPT_HOOK"; do + [ -f "$hook" ] && { + if [ "$2" ]; then + logv "$2" "Running $1 hook" + else + logv "Running $1 hook" + fi + break + } + done + + # Run all the hooks found in the configuration directory, and the user + # defined hook. + for hook in "$cpt_confdir/hooks/"* "$CPT_HOOK"; do set -f [ -f "$hook" ] || continue TYPE=${1:-null} PKG=${2:-null} DEST=${3:-null} . "$hook" done - - [ -f "$CPT_HOOK" ] || return 0 - - TYPE=${1:-null} PKG=${2:-null} DEST=${3:-null} . "$CPT_HOOK" } # An optional argument could be provided to enforce a compression algorithm. |