Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Go-syntax representation of the value #369

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/lefthook/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ func (r *Runner) runScript(script *config.Script, unquotedPath string, file os.F
args = strings.Split(script.Runner, " ")
}

quotedScriptPath := shellescape.Quote(unquotedPath)
quotedScriptPath := fmt.Sprintf("%#v", unquotedPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, so if I correctly understood, with Sprintf("%#v") the bug doesn't reproduce, right? Interesting 🤔
You know, a few releases before the path for scripts wasn't even quoted. I think this is a regression, and I added the quoting accidentally.

@stonesbg could you remove this line and rename the unquotedPath argument to be just path?

Good job with finding the reason for the buggy behavior! I appreciate it so much!

Copy link
Author

@stonesbg stonesbg Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully what I updated is what you meant. And yes once the Sprintf was changed things work in windows and wsl. I also tested with python script and a node script and both seemed to function correctly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all :) Let me help


args = append(args, quotedScriptPath)
args = append(args, r.args[:]...)

Expand Down