| 1 |
#!/bin/sh |
| 2 |
# SPDX-License-Identifier: BSD-3-Clause |
| 3 |
# |
| 4 |
# Copyright (C) 2019 Olliver Schinagl <[email protected]> |
| 5 |
# |
| 6 |
# A beginning user should be able to docker run image bash (or sh) without |
| 7 |
# needing to learn about --entrypoint |
| 8 |
# https://github.com/docker-library/official-images#consistency |
| 9 |
|
| 10 |
set -eu |
| 11 |
|
| 12 |
# run command if it is not starting with a "-" and is an executable in PATH |
| 13 |
if [ "${#}" -gt 0 ] && |
| 14 |
[ "${1#-}" = "${1}" ] && |
| 15 |
command -v "${1}" >"/dev/null" 2>&1; then |
| 16 |
exec "${@}" |
| 17 |
else |
| 18 |
# else default to run the command |
| 19 |
exec /bin/shfmt "${@}" |
| 20 |
fi |
| 21 |
|
| 22 |
exit 0 |