diff --git a/git-secrets b/git-secrets index 11be153..4f7ead2 100755 --- a/git-secrets +++ b/git-secrets @@ -203,7 +203,13 @@ install_hook() { [ -f "${dest}" ] && [ "${FORCE}" -ne 1 ] \ && die "${dest} already exists. Use -f to force" echo "#!/usr/bin/env bash" > "${dest}" - echo "git secrets --${cmd} -- \"\$@\"" >> "${dest}" + echo "err=\"\$(git secrets --${cmd} -- \"\$@\" 2>&1 > /dev/null)\"" >> "${dest}" + echo "if [[ \"\$err\" == *\"git: 'secrets' is not a git command\"* ]]; then" >> "${dest}" + echo " exit 0" >> "${dest}" + echo "elif [[ ! -z \"\$err\" ]]; then" >> "${dest}" + echo " >&2 echo \"\$err\"" >> "${dest}" + echo " exit 1" >> "${dest}" + echo "fi" >> "${dest}" chmod +x "${dest}" say "$(tput setaf 2)✓$(tput sgr 0) Installed ${hook} hook to ${dest}" }