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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command should use []string not string #45

Open
ghostsquad opened this issue Mar 5, 2022 · 3 comments
Open

Command should use []string not string #45

ghostsquad opened this issue Mar 5, 2022 · 3 comments
Labels
kind/enhancement Improvements or new features

Comments

@ghostsquad
Copy link
Contributor

Hello!

  • Vote on this issue by adding a 馃憤 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

Using string instead of []string for command means that the user must handle separating args, handling quoting issues, etc.

func CommandContext(ctx Context, name string, arg ...string)

I believe that a better user experience would be to allow the user to provide an array of args as well.

@ghostsquad
Copy link
Contributor Author

I think this is valuable, but it appears that native support for arg ...string doesn't exist for the Session in the ssh package. I asked around in the Gopher slack server, and no one had a better idea, other than to essentially not use the ssh package natively, and instead always use os.Exec and call ssh from there, which doesn't feel much better.

@ghostsquad
Copy link
Contributor Author

Maybe the right way to handle this would be to accept args []string and shellquote each arg, then join(" ", quotedArgs)?

I guess I'd have to write some tests.

https://github.com/frioux/leatherman/tree/main/pkg/shellquote

@guineveresaenger
Copy link

@pgavlin might have more insight here - we certainly welcome code changes but I want to make sure you're aligned in direction. <3

@lukehoban lukehoban added the kind/enhancement Improvements or new features label Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

4 participants