Skip to content

Conversation

paulc
Copy link

@paulc paulc commented Aug 25, 2023

Hello,

Really enjoying using script however there have been a couple of use cases where I have wanted to avoid interpolating the Exec args into a single cmdLIne (and worrying about quoting - which can be complex if dealing with arbitrary input) and have therefore added an Execv(cmd string, args []string) method which passes the cmd and args separately as []string (which is what gets passed to exec.Command anyway so saves re-parsing the command line).

Think this would be a useful addition (and be safer for scripts which make need to Exec commands where some of the parameters are untrusted)

…[]string vs inetrpolated into single cmdLine)
@paulc paulc mentioned this pull request Aug 25, 2023
Comment on lines +425 to +426
err := cmd.Start()
if err != nil {

Choose a reason for hiding this comment

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

Suggested change
err := cmd.Start()
if err != nil {
if err := cmd.Start(); err != nil {

@jesselang
Copy link
Contributor

I would very much appreciate having this slice-based Exec! Is this PR being considered?

```go
args := []string{};
args = append(args,"127.0.0.1")
script.Exec("ping",args).Stdout()

Choose a reason for hiding this comment

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

Would that be Execv?

Suggested change
script.Exec("ping",args).Stdout()
script.Execv("ping", args).Stdout()

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.

3 participants