Merge "Always use /bin/sh to run the command." am: 9e766acb09

Original change: https://android-review.googlesource.com/c/platform/build/+/1662423

Change-Id: I040645a94d981eb7e4aa383958691d742e78cb0d
This commit is contained in:
Treehugger Robot
2021-04-02 18:15:40 +00:00
committed by Automerger Merge Worker

View File

@@ -182,7 +182,7 @@ func shell(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple,
} }
if shellPath == "" { if shellPath == "" {
return starlark.None, return starlark.None,
fmt.Errorf("cannot run shell, SHELL environment variable is not set (running on Windows?)") fmt.Errorf("cannot run shell, /bin/sh is missing (running on Windows?)")
} }
cmd := exec.Command(shellPath, "-c", command) cmd := exec.Command(shellPath, "-c", command)
// We ignore command's status // We ignore command's status
@@ -234,8 +234,12 @@ func setup(env []string) {
"rblf_wildcard": starlark.NewBuiltin("rblf_wildcard", wildcard), "rblf_wildcard": starlark.NewBuiltin("rblf_wildcard", wildcard),
} }
// NOTE(asmundak): OS-specific. // NOTE(asmundak): OS-specific. Behave similar to Linux `system` call,
shellPath, _ = os.LookupEnv("SHELL") // which always uses /bin/sh to run the command
shellPath = "/bin/sh"
if _, err := os.Stat(shellPath); err != nil {
shellPath = ""
}
} }
// Parses, resolves, and executes a Starlark file. // Parses, resolves, and executes a Starlark file.