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

Allow for script.Exec() to be used like exec.Command() #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bartdeboer
Copy link
Contributor

A small update to allow for exec.Command(name string, arg ...string) style arguments.

script.Exec("go", "help")

@bitfield
Copy link
Owner

bitfield commented May 3, 2024

Hi @bartdeboer! Thanks for the PR.

Something that would be useful for documentation here is an example program showing where this feature would be used to solve a real-world problem. Can we come up with one?

@bartdeboer
Copy link
Contributor Author

A real world problem might be someone expecting the signature to work like exec.Command. I was now needing to look into the source and dependencies to find out what package was used to parse the command and see how it works with quoted arguments (arguments with spaces) etc. With this update people can use it either way they find most convenient.

@bitfield
Copy link
Owner

bitfield commented May 3, 2024

Right, but what I mean is, presumably there's some program that you wanted to write that you weren't able to write without this feature. A great way to explain the feature to someone would be to show them that program. Could you supply a suitable example?

@bartdeboer
Copy link
Contributor Author

Unfortunately I don't have an example program right now.

All I know is that exec.Command is widely used (also by script itself) and has served me well with complex commands. The shell.Fields method introduces a new approach to handling command lines unknown to me. Considering executing commands is such an important feature I think it will be nice to allow for such enhanced features while keeping the fallback on Go's core Exec functionality.

@bitfield
Copy link
Owner

bitfield commented May 5, 2024

As a user, I appreciate simple APIs, and simplicity doesn't happen by accident. It happens by imposing a high bar that new features have to clear, and one of those should certainly be "solves a problem that someone has".

To put it another way, if there's no problem, then there's no need for a PR! Let's keep it open, though, and this discussion might evolve to generate some use cases in the future.

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.

2 participants