Skip to content

Commit 58cbe53

Browse files
committed
cmd/buildlet: set a safe default for shell
On non-Linux, non-Windows OSes, gomotes use the value of the SHELL environment variable. If the variable is unset, starting gomote fails. Instead, set /bin/sh as a safe default. Fixes golang/go#70163. Change-Id: I88bdb2d83fa6d81eeccaffd1562fc8512bc0c4c5 Reviewed-on: https://go-review.googlesource.com/c/build/+/624796 Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Carlos Amedee <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 60c7972 commit 58cbe53

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd/buildlet/buildlet.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ var (
8888
// 26: clean up path validation and normalization
8989
// 27: export GOPLSCACHE=$workdir/goplscache
9090
// 28: add support for gomote server
91-
const buildletVersion = 28
91+
// 29: fall back to /bin/sh when SHELL is unset
92+
const buildletVersion = 29
9293

9394
func defaultListenAddr() string {
9495
if runtime.GOOS == "darwin" {
@@ -2039,6 +2040,9 @@ func shell() string {
20392040
case "windows":
20402041
return `C:\Windows\System32\cmd.exe`
20412042
default:
2042-
return os.Getenv("SHELL")
2043+
if shell := os.Getenv("SHELL"); shell != "" {
2044+
return shell
2045+
}
2046+
return "/bin/sh"
20432047
}
20442048
}

0 commit comments

Comments
 (0)