pre-commit/pre_commit/resources/hook-tmpl
Hugo Osvaldo Barrera b748138ed6 Use plain sh for the pre-commit script
Bash is currently a dependency of pre-commit. It is only used in the
pre-commit script, and the only bash-specific feature that is used is a
single array.

Use the `args` array instead, which works on plain sh (e.g.: POSIX sh).
This change drops bash as a runtime dependency.

Tested with busybox sh(ash) and OpenBSD's sh(ksh).
2025-03-03 10:33:59 +01:00

21 lines
508 B
Bash
Executable file

#!/bin/sh
# File generated by pre-commit: https://pre-commit.com
# ID: 138fd403232d2ddd5efb44317e38bf03
# start templated
INSTALL_PYTHON=''
ARGS="hook-impl"
# end templated
HERE="$(cd "$(dirname "$0")" && pwd)"
set -- $ARGS --hook-dir "$HERE" -- "$@"
if [ -x "$INSTALL_PYTHON" ]; then
exec "$INSTALL_PYTHON" -mpre_commit "$@"
elif command -v pre-commit > /dev/null; then
exec pre-commit "$@"
else
echo '`pre-commit` not found. Did you forget to activate your virtualenv?' 1>&2
exit 1
fi