我有以下bash脚本。如何使基于grep正则表达式的bash脚本失败?
我试图解决的问题非常简单。当Git中的提交否以gh-1234 ...
开头时,它应该失败。
这个bash脚本有什么问题?
commit_regex='(gh-[0-9]+|merge)'
error_msg="Aborting commit. Your commit message is missing either a Github Issue ('gh-1111') or 'Merge'."
if ! grep -q "$commit_regex" <<< "$1"; then
echo "$error_msg" >&2
exit 1
fi
我想你想'grep -E'? – psmears