diff --git a/internal/views/exec.go b/internal/views/exec.go index 06427a48..cf0756e9 100644 --- a/internal/views/exec.go +++ b/internal/views/exec.go @@ -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...) } diff --git a/internal/views/pod.go b/internal/views/pod.go index 4a1e323d..140f835a 100644 --- a/internal/views/pod.go +++ b/internal/views/pod.go @@ -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") } diff --git a/internal/views/pod_test.go b/internal/views/pod_test.go index 39c41b06..2957e23d 100644 --- a/internal/views/pod_test.go +++ b/internal/views/pod_test.go @@ -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", }, }