[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Hook Scripts; How to Send Message to User?

From: David Weintraub <qazwart_at_gmail.com>
Date: Tue, 9 Jun 2009 11:26:26 -0400

Your hook is a Perl script? Let's do it the easy way: In your Perl script,
use the "select" command to select STDERR as the default file descriptor for
output:

    select(STDERR);

Now, everytime you use a "print" in your Perl script, it'll go to STDERR
instead of STDOUT.

You can also do this too:

    print STDERR "$message\n";

Also remember that the hook has to fail before you see what was sent to
STDERR. (It looks like you're doing this anyway).

On Tue, Jun 9, 2009 at 11:17 AM, Tom Browder <tom.browder_at_gmail.com> wrote:

> I have a pre-commit hook script that is properly aborting the commit
> according to my rules, but I can't get the script's message to the
> user.
>
> The book says anything written to stderr is marshalled to the user,
> but I can't find any examples of how to do that successfully.
>
> I have this in my hooks/pre-commit
>
> ===>
> # Check that the incoming files meet name requirements.
> /path/to/check-allowed-names.pl $1 $2 > /dev/null 2>&1
> if [ $? != '0' ] ; then
> cat /path/to/msg 2>&1
> exit 1
> fi
> <===
>
> Then I try to commit a file with disallowed name:
>
> $ svn ci badname -m"test"
> Adding (bin) badname
> Transmitting file data .svn: Commit failed (details follow):
> svn: Commit blocked by pre-commit hook (exit code 255) with no output.
> $
>
> The Perl script called by pre-commit writes to STDERR.
>
> I have tried writing to an explicit file and then using cat in
> pre-commit, but I can't control its output message at all.
>
> What am I doing wrong? How does one get the called script's error
> messages to the user?
>
> Thanks.
>
> -Tom
>
> ------------------------------------------------------
>
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2360658
>
> To unsubscribe from this discussion, e-mail: [
> users-unsubscribe_at_subversion.tigris.org].
>

-- 
David Weintraub
qazwart_at_gmail.com
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2360662
To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-06-09 17:27:24 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.