Skip to content

fix(hooks): skip bash syntax check on Windows - #484

Open
Firefly0619sec wants to merge 1 commit into
winfunc:mainfrom
Firefly0619sec:fix/hook-validation-windows
Open

Firefly0619sec wants to merge 1 commit into
winfunc:mainfrom
Firefly0619sec:fix/hook-validation-windows

Conversation

@Firefly0619sec

Copy link
Copy Markdown

Problem

validate_hook_command always runs bash -n -c <command>:

let mut cmd = std::process::Command::new("bash");
cmd.arg("-n").arg("-c").arg(&command);

On Windows there is no bash on the default PATH (unless Git Bash/WSL is installed), so the command fails with Failed to validate command: ... program not found and the hooks editor cannot validate anything.

Change

On Windows, skip the syntax check and return valid: true with a short message, instead of erroring out. The hook is still executed by whatever shell the user configured; this only affects the optional syntax pre-check.

Notes

  • Non-Windows behavior is unchanged;
  • If you prefer a real check on Windows, a follow-up could use powershell -NoProfile -Command "[scriptblock]::Create($cmd)", but hooks are often bash syntax, so skipping is the safer default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant