-
Notifications
You must be signed in to change notification settings - Fork 254
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
sh syntax error when running on windows: -c: line 3: syntax error: unexpected end of file .
lefthook.yml
colors: false
test:
jobs:
- name: test
run: |
if [ -z "$CI" ]; then
echo "NO CI"
else
echo "CI"
fiCommands to reproduce
$ $env:LEFTHOOK_VERBOSE='true'
$ lefthook run test
│ [lefthook] git: git version
│ out: git version 2.51.0.windows.2
│ [lefthook] git: git rev-parse --path-format=absolute --show-toplevel --git-path hooks --git-path info --git-dir
│ out: C:/Users/xxxx/workspaces/projects/xxx
│ C:/Users/xxxx/workspaces/projects/xxx/.git/hooks
│ C:/Users/xxxx/workspaces/projects/xxx/.git/info
│ C:/Users/xxxx/workspaces/projects/xxx/.git
│ loading config: C:\Users\xxxx\workspaces\projects\xxx\lefthook.yaml
╭──────────────────────────────╮
│ lefthook v1.13.6 hook: test │
╰──────────────────────────────╯
│ [lefthook] run: "C:\Program Files\Git\bin\sh.exe" -c "if [ -z "$CI" ]; then
│ echo "NO CI"
│ else
│ echo "CI"
│ fi
│ "
⠙ waiting: testCI
else
echo CI
fi
: -c: line 3: syntax error: unexpected end of file
│ [lefthook] git: git diff --name-only --cached --diff-filter=ACMR
│ [lefthook] git: git diff --name-only --cached --diff-filter=ACMRD
│ [lefthook] git: git status --short --porcelain
│ out: M lefthook-nodejs.yaml
│ M lefthook.yaml
│ ?? CHANGELOG.md
┃ test ❯
────────────────────────────────────
summary: (done in 0.19 seconds)
✗ test (0.19 seconds)Lefthook version
1.13.6 539f66c92f10e20ed369d769afee1cd6e93d5735
Possible solution
Thank you for creating this excellent software!
I found the problem occurs here:
| cmdLine := "\"" + sh + "\"" + " -c " + "\"" + cmdstr + "\"" |
I'm not familiar with the golang and don't understand why it can't be passed as a parameter like unix:
| command := exec.CommandContext(ctx, "sh", "-c", cmdstr) |
Or we can also use a temp file or stdin for sh to read to avoid this problem.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working