#!/bin/bash # afterShellExecution: log command output (truncated), useful for lint runs HOOKS_DIR="$(cd "$(dirname "$0")" && pwd)" # shellcheck source=lib.sh . "${HOOKS_DIR}/lib.sh" input=$(cat) command=$(echo "$input" | jq -r '.command // ""') duration=$(echo "$input" | jq -r '.duration // 0') output=$(echo "$input" | jq -r '.tool_output // .command_output // ""' 2>/dev/null || echo "$input" | jq -r '.command_output // ""' 2>/dev/null) # Some hooks use tool_output, others command_output - try both if [ -z "$output" ]; then output=$(echo "$input" | jq -r '.tool_output // ""' 2>/dev/null) fi log_event "afterShellExecution" "cmd=${command:0:80} duration=${duration}ms" if [ -n "$output" ] && [ ${#output} -gt 0 ]; then log_json_truncated "afterShellExecution_output" "$output" 400 fi echo '{}' exit 0