-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
I'm writing a Shell interpreter in Go and I've come across a limitation in the os/exec package. In particular, when it comes to the interpreter state keeping track of the environment variable PATH.
exec.LookPath is hard-coded to using os.Getenv("PATH"), and so exec.Command is too. This is unfortunate as it means that the interpreter must modify the process's PATH to be able to use its own when running a command. But as you can imagine, that will not work well if there are multiple interpreters running concurrently.
Would it be possible for os/exec to have a LookPath version that got PATH from a string argument or similar? Then the existing LookPath could be rewritten in terms of it. In other words, a LookPath version that didn't depend on the process's environment.
I realise it's a bit of a bizarre request, but I can't figure out another way to do it other than maintaining a fork of LookPath myself.