🐛 Fix "shell" keyword losing its interpreter after shift 🐛
Build and Push / build (push) Failing after 1s

- 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 ab4251e480) 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.
This commit is contained in:
2026-07-27 17:29:50 -04:00
parent ab4251e480
commit 88544fdf50
+13 -2
View File
@@ -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