Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: keep PATH list separators OS-specific
A recent commit, 1eb295c, introduced a regression on Windows. Programs spawned by interp no longer found other programs in PATH. The reason turns out to be because those programs saw a Unix-like PATH, with the list separator being ":" rather than ";", which breaks Windows programs as they see one single mangled directory. The actual source of the bug is much older, from eb75bb8f7d: For better compatibility with non-unix systems, convert $PATH to a unix path list when starting the interpreter. This should work with Windows, for example. The recent commit surfaced the bug by tweaking the environment logic. Before, converting PATH's list separators was an internal detail, but now we also export this change and it affects spawned programs. The added test case fails without the fix: --- FAIL: TestRunnerRun/mvdan#883 (0.19s) interp_test.go:3201: wrong output in "GOSH_CMD=lookpath $GOSH_PROG": want: "cmd found\n" got: "exec: \"cmd\": executable file not found in %PATH%\nexit status 1" The fix is relatively simple: stop converting PATH's list separators. I believe the reason I originally added that code was for compatibility, so that scripts using Unix-like path list separator, such as export PATH="${PATH}:${PWD}" would work as expected on Windows. However, I struggle to agree with my past self on that approach. We had no tests for this behavior, and any script using Unix-like paths in any non-trivial way would likely need to be adjusted to be compatible with Windows anyway. Fixes mvdan#768.
- Loading branch information