From 88544fdf50e95b3f98623018149794f286c634e0 Mon Sep 17 00:00:00 2001 From: casjay Date: Mon, 27 Jul 2026 17:29:50 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20"shell"=20keyword=20losing?= =?UTF-8?q?=20its=20interpreter=20after=20shift=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rootfs/usr/local/bin/entrypoint.sh: the shared case branch for */bin/sh|*/bin/bash|bash|sh|shell only conditionally shifted $1 when it equaled "shell", but the remaining args (e.g. "-c" "echo cmd") then went straight to __exec_command's `exec "$@"` with no interpreter left to run them — `docker run image shell -c 'echo cmd'` failed with "exec: echo cmd: not found" (exit 127). "shell" is a keyword, not a real executable, so after shifting it away the remaining args need "sh" prepended. Split the case into two branches: real interpreter names (*/bin/sh, */bin/bash, bash, sh) pass through unshifted as before; "shell" gets its own branch that shifts and calls `__exec_command sh "$@"` when args remain, or bare `__exec_command` (falls back to `exec bash -l`) when none do. Verified `bash -n` passes; script-lint confirms the edited block is clean. Found while functional-testing the previous sh/bash -c fix (commit ab4251e4805c) against a freshly rebuilt image — sh -c/bash -c now work, but `docker run casjaysdev/go:latest shell -c 'echo shell-cmd-ok'` still failed until this fix. --- rootfs/usr/local/bin/entrypoint.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/rootfs/usr/local/bin/entrypoint.sh b/rootfs/usr/local/bin/entrypoint.sh index 1024cd9..e2a7887 100755 --- a/rootfs/usr/local/bin/entrypoint.sh +++ b/rootfs/usr/local/bin/entrypoint.sh @@ -629,11 +629,22 @@ procs) # Launch shell — do not shift here: "sh -c 'cmd'" / "bash -c 'cmd'" needs the # interpreter name kept as argv[0] for __exec_command's `exec "$@"` to work; # shifting it away turned "sh -c 'cmd'" into `exec -c cmd` (command not found) -*/bin/sh | */bin/bash | bash | sh | shell) - [ "$1" = "shell" ] && shift 1 +*/bin/sh | */bin/bash | bash | sh) __exec_command "$@" exit $? ;; +# "shell" is a keyword, not a real interpreter — it must be shifted away, and +# any remaining args need "sh" prepended so __exec_command's `exec "$@"` gets +# a real interpreter instead of trying to exec "-c" as a program +shell) + shift 1 + if [ $# -eq 0 ]; then + __exec_command + else + __exec_command sh "$@" + fi + exit $? + ;; # execute commands exec) shift 1