title: POST-COMMIT SCRIPT of SVN to check commit log for PRODUCT-ID using shell script
body: <p>I am new to Linux as well as for Subversion. I had a task to check the syntax of the commit message to contain PRODUCT ID. If its not present I have pass a message to user saying an invalid format using SHELL SCRIPT.<br>
  Below are the steps I had followed after a lot search in google,
  For the PRE-COMMIT hook the code is:  </p>
  
  <pre><code>#!/bin/sh  
  set -e  
  /PATH-TO-REPOSITORY/hooks/CommentSyntax.sh "$1" "$2"  
  </code></pre>
  
  <p>My CommentSyntax.sh script is,  </p>
  
  <pre><code>#!/bin/sh  
  REPOS="$1"  
  TXN="$2"  
  SVNLOOK=/usr/bin/svnlook  
  regex="PRODUCT-[0-9]*"  
  if [ `"$SVNLOOK" log -t "$TXN" "$REPOS"` =~ ${regex} ]; then  
      exit 0  
  else  
    echo "" 1&gt;&amp;2    
    echo "Please make your commit comment start with PRODUCT-XXX" 1&gt;&amp;2  
    exit 1  
  fi
  </code></pre>
  
  <p>Whenever I am trying to check-in the code, am getting the below error,</p>
  
  <pre><code>srikanth:~/testing$ svn ci -m "PRODUCT-123"
  Sending        two.java
  Transmitting file data .svn: Commit failed (details follow):
  svn: Commit blocked by pre-commit hook (exit code 1) with output:
  [: 22: PRODUCT-123: unexpected operator
  
  Please make your commit comment start with PRODUCT-XXX
  </code></pre>
  
  <p>I am not sure where I gone wrong. Request your valuable advice on the same.</p>