Merge pull request #228 from JrCs/use-best-shell

Use the best shell
mine
Fernand Galiana 2019-06-12 21:36:00 -07:00 committed by GitHub
commit 15a9885d16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 15 deletions

View File

@ -20,16 +20,6 @@ func runK(clear bool, app *appView, args ...string) bool {
return false
}
last := len(args) - 1
if args[last] == "sh" {
args[last] = "bash"
if !run(clear, app, bin, args...) {
args[last] = "sh"
} else {
return true
}
}
return run(clear, app, bin, args...)
}

View File

@ -241,5 +241,5 @@ func computeShellArgs(path, co, context string, kcfg *string) []string {
args = append(args, "-c", co)
}
return append(args, "--", "sh")
return append(args, "--", "sh", "-c", "command -v bash >/dev/null && exec bash || exec sh")
}

View File

@ -19,28 +19,28 @@ func TestComputeShellArgs(t *testing.T) {
"c1",
"ctx1",
&config,
"exec -it --context ctx1 -n fred blee --kubeconfig coolConfig -c c1 -- sh",
"exec -it --context ctx1 -n fred blee --kubeconfig coolConfig -c c1 -- sh -c command -v bash >/dev/null && exec bash || exec sh",
},
"noconfig": {
"fred/blee",
"c1",
"ctx1",
nil,
"exec -it --context ctx1 -n fred blee -c c1 -- sh",
"exec -it --context ctx1 -n fred blee -c c1 -- sh -c command -v bash >/dev/null && exec bash || exec sh",
},
"emptyConfig": {
"fred/blee",
"c1",
"ctx1",
&empty,
"exec -it --context ctx1 -n fred blee -c c1 -- sh",
"exec -it --context ctx1 -n fred blee -c c1 -- sh -c command -v bash >/dev/null && exec bash || exec sh",
},
"singleContainer": {
"fred/blee",
"",
"ctx1",
&empty,
"exec -it --context ctx1 -n fred blee -- sh",
"exec -it --context ctx1 -n fred blee -- sh -c command -v bash >/dev/null && exec bash || exec sh",
},
}