-
Notifications
You must be signed in to change notification settings - Fork 72
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
Running intermediate try scripts with the original shell #7
Comments
@mgree and @dspinellis any thoughts? I can implement the |
I don't think the ps way is accurate enough, because it gives the name of the command that invoked the shell, but not the actual shell path. For example, if I execute a script with
|
I agree that Also: these APIs only exist on Linux and FreeBSD, so we don't need to worry about macOS portability. |
@mgree which APIs do you speak of? Are you referring to the APIs exposed by |
I'm talking about |
try
currently runs the intermediate temporary scripts that it creates using/bin/sh
. This causes a problem if we want the internal script to run using a different shell and therefore inherit its state, e.g., bash functions.A running example of the wanted behavior follows:
I think that a good portable solution would be to run the intermediate scripts with whatever shell try is running too. What is a portable way to determine which shell we are running on? Here are some alternatives:
$SHELL
variable will contain the name of the login shell (it doesn't work if the subprocess is different than the login shell)ps
, e.g.,ps -o args= -p "$$"
orps -o command= -p "$$"
. This seems to me like the most portable and correct solution.Here are some SO posts that discuss this issue:
Note that we don't really care about the underlying shell, we just want the executable (or even a link to it), so if try was invoked using
/bin/sh
we can just use that, we don't care that it was bash under the hood.The text was updated successfully, but these errors were encountered: