You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Ryan Schmidt <su...@ryandesign.com> on 2005/11/17 12:17:56 UTC

Re: How do i set up post commit hook script?

On Oct 24, 2005, at 12:17, Uppal, Deepali wrote:

> post-commit executable contains the following:
> ----------------------------------------------------------------------
> set -xv
>
> REPOS="$1"
> REV="$2"
>
> /home/developer/subversion-1.2.0-rc4/tools/hook-scripts/commit- 
> email.pl
> "$REPOS" "$REV" <email-id>
>
> exit 2
> ----------------------------------------------------------------------
>
> The script commit-email.pl has not been changed by me. It is the one
> shipped with subversion release-1.2.3.


For anyone else wondering: Even though the path to the script shows  
the subversion-1.2.0-rc4 directory, it looks like the script was not  
changed between then and 1.2.3.


> When I run post-commit from the command line I get the following error
> messages:
>
> Use of uninitialized value in -d at commit-email.pl line 224.
> sh: -c: line 1: unexpected EOF while looking for matching ``'
> sh: -c: line 2: syntax error: unexpected end of file
> Broken pipe


Ok. Let's see.

I don't know what "set -xv" is.

As you already know, "Use of uninitialized value in -d at commit- 
email.pl line 224" occurs when one doesn't have the environment  
variable TEMP set. This error message was suppressed in trunk r16801,  
was merged to the 1.3 branch in r16813 and was included in Subversion  
1.3.0-rc1.


There is definitely an error in the script's validation of the  
revision parameter. It's meant to be checking that the revision is an  
integer, but it only succeeds in verifying that it starts with an  
integer. The fix is as follows:

--- commit-email.pl.in  2005-11-17 12:17:06.000000000 +0100
+++ commit-email.pl.in     2005-11-17 12:39:56.000000000 +0100
@@ -174,7 +174,7 @@
# Check the validity of the command line arguments.  Check that the
# revision is an integer greater than 0 and that the repository
# directory exists.
-unless ($rev =~ /^\d+/ and $rev > 0)
+unless ($rev =~ /^\d+$/ and $rev > 0)
    {
      &usage("$0: revision number `$rev' must be an integer > 0.");
    }


Before applying this fix I tried calling the script from the command  
line with the revision parameter "1u" which is clearly not a valid  
revision, yet passes the broken validation test. This causes the  
following errors to be printed:

Argument "1u" isn't numeric in numeric gt (>) at ./commit-email.pl  
line 177.
Use of uninitialized value in -d at ./commit-email.pl line 224.
sh: -c: line 1: unexpected EOF while looking for matching ``'
sh: -c: line 2: syntax error: unexpected end of file
Broken pipe

This is presumably because somewhere in the script the ludicrous  
misuse of the backtick as an opening quote mark is being interpreted  
by the shell as the start of a subcommand execution, which is clearly  
going to break all over the place since it's not a command and  
there's no closing backtick. Since I cannot so easily determine which  
of the seventeen backtick-containing messages is causing this  
(although in my case it appears to be the very last one, in the  
return statement on line 599), and since the backtick is definitely  
not a typographically acceptable substitute for an opening quote, my  
solution to this is to remove the backticks from the code:

cp commit-email.pl commit-email.pl.bak && sed 's/`/'\''/g' commit- 
email.pl.bak > commit-email.pl

Yes, I double-checked first that all seventeen backticks are only  
being used in diagnostic messages, never with the intention of  
actually executing a command.

This should remove the "sh" and "Broken pipe" error messages, and  
with some luck, show you the real reason your mails aren't being  
sent. Let us know.


I would like to write up bug reports for these two issues, since I  
cannot find any existing issues for them.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org