From 7934e64507cff89382ecfb280855878cf2f80ab2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 13 Oct 2025 14:25:33 -0700 Subject: [PATCH] Update pre-bash-zig-build.js --- .claude/hooks/pre-bash-zig-build.js | 34 ++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.claude/hooks/pre-bash-zig-build.js b/.claude/hooks/pre-bash-zig-build.js index 24b47b06fc..d65b8b43d7 100755 --- a/.claude/hooks/pre-bash-zig-build.js +++ b/.claude/hooks/pre-bash-zig-build.js @@ -92,7 +92,39 @@ if (argv0 === "timeout") { // Check if it's "bun bd" or "bun-debug bd" without other positional args if (actualCommand === "bun" || actualCommand.includes("bun-debug")) { - const positionalArgs = restArgs.filter(arg => !arg.startsWith("-")); + // Claude is a sneaky fucker + let positionalArgs = restArgs.filter(arg => !arg.startsWith("-")); + const redirectStderrToStdoutIndex = positionalArgs.findIndex(arg => arg === "2>&1"); + if (redirectStderrToStdoutIndex !== -1) { + positionalArgs.splice(redirectStderrToStdoutIndex, 1); + } + const redirectStdoutToStderrIndex = positionalArgs.findIndex(arg => arg === "1>&2"); + if (redirectStdoutToStderrIndex !== -1) { + positionalArgs.splice(redirectStdoutToStderrIndex, 1); + } + + const redirectToFileIndex = positionalArgs.findIndex(arg => arg === ">"); + if (redirectToFileIndex !== -1) { + positionalArgs.splice(redirectToFileIndex, 2); + } + + const redirectToFileAppendIndex = positionalArgs.findIndex(arg => arg === ">>"); + if (redirectToFileAppendIndex !== -1) { + positionalArgs.splice(redirectToFileAppendIndex, 2); + } + + const redirectTOFileInlineIndex = positionalArgs.findIndex(arg => arg.startsWith(">")); + if (redirectTOFileInlineIndex !== -1) { + positionalArgs.splice(redirectTOFileInlineIndex, 1); + } + + const pipeIndex = positionalArgs.findIndex(arg => arg === "|"); + if (pipeIndex !== -1) { + positionalArgs = positionalArgs.slice(0, pipeIndex); + } + + positionalArgs = positionalArgs.map(arg => arg.trim()).filter(Boolean); + if (positionalArgs.length === 1 && positionalArgs[0] === "bd") { denyWithReason("error: Run `bun bd` without a timeout"); }