I'd like to understand what this script does. It's defined as the entrypoint for the node-14 docker-image. We have issues with our environment variables disappearing on this new version and I'm wondering if it has to do with this script (the env vars have some special characters in them). Could someone break it down for me?

set -e

if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
  set -- node "$@"

exec "$@"

1 Answer 1


[ "${1#-}" != "${1}" ] -- "first parameter starts with a dash"

[ -z "$(command -v "${1}")" ] -- "cannot find a binary with a name set in the first parameter ${1}"

set -- node "$@" -- "insert 'node' at the first place in the parameters list"

exec "$@" -- "take all the parameters as a string and execute it"

Looks like this has nothing to do with environment variables.

P.S. I think in the second block of code (with "command") the inner double quotes should be escaped.

  • I think the part that has to do with environment variables is just that this runs everything through sh, which is very picky (compared to bash) in the characters it allows in environment variables.
    – joniba
    Jul 16, 2021 at 6:37
  • Maybe. But with the provided info it is just guessing. If you need to get to the root of the problem, you should ask a new question with more info like your environment, the way you start the container. Preferably with the standard of presenting a question: what you do, what you expect to get, what you actually get.
    – trolzen
    Jul 16, 2021 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.