chore: ensure Husky script runs under bash (#71)

This commit is contained in:
Jonathan Yu 2021-05-24 13:21:28 -07:00 committed by GitHub
parent 60abdec164
commit da1e6d4c84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,19 @@
#!/usr/bin/env bash
# The ./_/husky.sh script always runs this script using "sh" in order
# to try to capture the exit code. This means that bash-isms can cause
# an error message. Some distros, such as Arch, use bash for /bin/sh,
# so do not experience this problem, but this is non-standard and
# Debian-based distributions (including Ubuntu) use dash for /bin/sh.
#
# We work around this by detecting whether we are running under Bash,
# by looking for the BASH environment variable, and replacing the
# current script with a version under Bash by using exec. For details,
# see https://github.com/typicode/husky/issues/971.
if [ -z "${BASH:-}" ]; then
exec bash "$0" "$@"
fi
source "$(dirname "$0")/_/husky.sh"
set -euo pipefail