Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way for me to simplify this pre-commit hook? It seems a bit much to me

message=`$SVNLOOK log -t "$TXN" "$REPOS"`

# Block any commits which don't reference a ticket
if echo $message | grep -q "re #"
elif echo $message | grep -q "references #"
elif echo $message | grep -q "refs #"
elif echo $message | grep -q "see #"
elif echo $message | grep -q "addresses #"
    echo "Your commit must reference a ticket to be accepted. For example, re #1234"
share|improve this question
up vote 1 down vote accepted

For this, you could use either gnur's variant or use a pattern file:

grep -q --file="matchpatterns.txt" 

which would contain every pattern you want to accept:

refs #
addresses #
ticket #
bug #

I like this more because this kind of list tends to become long very quick, making the inline pattern difficult to manage.

share|improve this answer
This is definitely the simplest and easiest to maintain! – David Sep 12 '11 at 1:31

if echo $message | grep -q '\(re\|references\|refs\|see\|addresses\|\) #'

Should do the trick.

share|improve this answer
very nice, I should have known that regex has OR syntax! – David Sep 12 '11 at 1:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.