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

Proposal: sh("<cmd> ...") as alias for sh.bash("-c", "<cmd> ...") #735

Closed
axsaucedo opened this issue Oct 6, 2024 · 4 comments · Fixed by #736
Closed

Proposal: sh("<cmd> ...") as alias for sh.bash("-c", "<cmd> ...") #735

axsaucedo opened this issue Oct 6, 2024 · 4 comments · Fixed by #736

Comments

@axsaucedo
Copy link
Contributor

axsaucedo commented Oct 6, 2024

Using sh extensively I often find myself having to use the sh.bash("-c", "<cmd> ..."). Although the sh.<cmd> interface is great initially for convenience, I often find myself adding the full command directly, whether for easier consistency when testing or due to limitations such as commands that contain a special character (-, ., etc). Indeed it's possible to bash = sh.bash.bake("-c") which is what I tend to do instead, but it would be quite convenient if this was supported by default as a contrib command that is accessible directly from the callable interface, and could potentially be a relatively simple interface (e.g. a __call__ implementation). Thanks for the great project!

@amoffat
Copy link
Owner

amoffat commented Oct 6, 2024

Is the request something like this?

from sh.contrib import bash
bash.ls() # runs bash -c ls

@axsaucedo
Copy link
Contributor Author

Thank you for your prompt reply! Yes exactly, the only extra I would add is being able to call directly - e.g:

from sh.contrib import bash
bash("command-with-dash [...]") # runs bash -c <cmd> [...] directly

@amoffat
Copy link
Owner

amoffat commented Oct 6, 2024

Ok, I would merge it if you (or someone) made a PR. Here's the git contrib command to use as a template https://github.com/amoffat/sh/blob/develop/sh.py#L3467-L3471

@axsaucedo
Copy link
Contributor Author

Sounds good @amoffat - added #736 with functionality discussed:

image

Let me know if further changes requred - thanks!

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 a pull request may close this issue.

2 participants