]> git.corax.cc Git - toolbox/commitdiff
utils/ipc-tap: Check if a hook is present before executing it
authorMatthias Kruk <m@m10k.eu>
Sat, 8 Oct 2022 04:26:53 +0000 (13:26 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 8 Oct 2022 04:26:53 +0000 (13:26 +0900)
When ipc-tap calls per-topic hooks, it does not check if a hook was
set, causing an error to be emitted when no hook for a topic was set.

This commit modifies ipc-tap so that it checks if a hook is set before
executing it.

utils/ipc-tap.sh

index df49a1364077181a2dde921eab85e3cab9c1f2c6..265c1d9100a9f00ed7d3d63c18d82d837f5688cc 100755 (executable)
@@ -67,8 +67,12 @@ invoke_hooks() {
        local message="$2"
 
        local data
+       local hook
+
+       hook="${hooks[$topic]}"
 
-       if data=$("${hooks[$topic]}" <<< "$message") &&
+       if [[ -n "$hook" ]] &&
+          data=$("$hook" <<< "$message") &&
           [[ -n "$data" ]]; then
                output_message "HookData" "$data"
        fi