-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Is your feature request related to a problem? Please describe.
It's quite common to need to run a command through the user's shell - in order to get access to whatever path they have set up in their various profile scripts.
Let's say the user has cowsay
installed via homebrew (likely installed at /opt/homebrew/bin/ on Apple Silicon Macs) then:
try await run(.name("cowsay"))
Will fail because it can't find cowsay in the user's path.
Describe the solution you'd like
What I think is the best solution to this would to provide an API like that works like this:
try await run(.name("cowsay", shell: .user))
The shell parameter would instruct Subprocess to look up the user's shell via getpwuid
and effectively convert the command into the following, selecting the user's shell as appropriate, and running it through the shell with -l as a login shell.
/opt/homebrew/bin/fish -l -c cowsay
Describe alternatives you've considered
It's possible for user code to do themselves or to provide UI for the user to specify their shell. But this feels something that Subprocess should provide.
Additional context
I am not sure how this should work on Windows.
Also the -l -c and/or other shell arguments impose some complexity on how the final arguments are constructed.