From 5c6f2d7dc5ae9aad10d734f168d323709c592bcc Mon Sep 17 00:00:00 2001 From: Andy Zhou Date: Fri, 24 May 2019 10:50:12 -0700 Subject: [PATCH] Avoid hard coding the bash path OS distribution and user may choose to install bash in different path. This patch uses bash found by "$PATH" environment, rather than hard code the bash path. This patch also handle the case 'bash' are not found. Mostly likely due to bash not being supported by the platform, or it is not installed. --- cli/shell.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/shell.go b/cli/shell.go index 6dbc772b..a3bdaf37 100644 --- a/cli/shell.go +++ b/cli/shell.go @@ -11,7 +11,13 @@ func bashShell(cluster string) error { if err != nil { return err } - cmd := exec.Command("/bin/bash", "--noprofile", "--norc") + + bashPath, err := exec.LookPath("bash") + if err != nil { + return err + } + + cmd := exec.Command(bashPath, "--noprofile", "--norc") // Set up stdio cmd.Stdout = os.Stdout