Open bbodenmiller opened 2 years ago
Most probably command is run in Windows shell (cmd?) but your syntax is for Unix sh-compatible ones.
Try to wrap your command into shell like this:
run: bash -c "if grep -c 'password' {staged_files}; then exit 1; fi"
Haven't worked in Windows for years, so can't really suggest a specific solution.
Or try to move commands to scripts.
Most probably command is run in Windows shell (cmd?) but your syntax is for Unix sh-compatible ones.
I thought the same but run command of unix2dos {staged_files}
works fine in config (and does not work in cmd).
I'm getting this error more when I try to run with GitHub Desktop. I think it's a GitHub Desktop problem in those cases but interested in others opinion: https://github.com/desktop/desktop/issues/13052
Oh, yes, GUI tools have problems with PATH
. See https://github.com/evilmartians/lefthook/issues/178 for example (especially https://github.com/evilmartians/lefthook/issues/178#issuecomment-833305335)
@Envek can you pass {staged_files}
to scripts? I couldn't figure out how to based on docs and experimentation.
FYI
run: bash -c "if grep -c 'password' {staged_files}; then exit 1; fi"
Does not work. It throws
⠹ waiting bash: -c: line 0: syntax error near unexpected token `then'
bash: -c: line 0: `\if grep -c 'password' myfile.config; then exit 1; fi"'
Lefthook on Windows is not supposed to use bash
. BTW you can just use grep
here, it will exit 1 when no match found. So, no need for if
statement.
Trying to run this simple command on Windows but getting the error
exec: "if": executable file not found in %PATH%