You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
You're writing a shell interpreter. It's okay to fork something like LookPath if you need something non-standard.
There's no reason to pollute the standard library with something that two people need. That means everybody else in the ecosystem needs to read over your new LookPath docs just to realize it wasn't what they were looking for.
Feel free to put yours up at github.com/mvdan/lookpath
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 variablePATH
.exec.LookPath
is hard-coded to usingos.Getenv("PATH")
, and soexec.Command
is too. This is unfortunate as it means that the interpreter must modify the process'sPATH
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 aLookPath
version that gotPATH
from astring
argument or similar? Then the existingLookPath
could be rewritten in terms of it. In other words, aLookPath
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.The text was updated successfully, but these errors were encountered: