-
Notifications
You must be signed in to change notification settings - Fork 162
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
support commands specified as exe/args #483
Conversation
Thank you for the quick PR. I'll check this soon. |
process.go
Outdated
if exeArgs, _ := shellwords.Parse(exe); len(exeArgs) > 0 { | ||
// We want to return the original error if this command isn't found so | ||
// do not overwrite it. | ||
if p, err2 := execabs.LookPath(exeArgs[0]); err2 == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if p, err2 := execabs.LookPath(exeArgs[0]); err2 == nil { | |
if p, err := execabs.LookPath(exeArgs[0]); err == nil { |
Would you shadow the outer err
variable? It is okay because this variable is very short-lived.
process_test.go
Outdated
func TestProcessRunWithArgs(t *testing.T) { | ||
var done atomic.Bool | ||
p := newConcurrentProcess(1) | ||
echo := testSkipIfNoCommand(t, p, "echo hello") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test doesn't fail when newCommandRunner
fails because it calls t.Skip
.
Instead, we need to check if echo
exists separately.
if _, err := execabs.LookPath("echo"); err != nil {
t.Skipf("echo command is necessary to run this test: %s", err)
}
c, err := p.newCommandRunner("echo hello", false)
if err != nil {
t.Fatalf(`parsing "echo hello" failed: %v`, err)
}
Thanks @rhysd applied the fixes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you for the updates.
closes #480
If an external command (shellcheck, pyflakes) is not found, try to parse it as a exe+args using go-shellwords, which can allow executing without having the binary installed i.e.,
go run github.com/wasilibs/go-shellcheck/cmd/[email protected]
,pipx run pyflakes
.