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

Re: Hooks and Perl on Windows

From: Toby Johnson <toby_at_etjohnson.us>
Date: 2004-11-22 20:35:04 CET

Jason Butlin wrote:

> If I run the hook batch file from the command line (with the necessary
> tweaks to get it working), when the Perl script returns the DOS
> ERRORLEVEL variable is correctly set to 1 or 0, depending upon the
> exit call of the Perl script. However, when the batch file is run from
> SVN, the errorlevel code is always 0.
>
> Anyone got any ideas as to why this is?

The problem is that even though your perl script is exiting with a
non-zero status, the batch script will always exit with a zero status
unless a problem occurs in the batch file.

A way to trick it into sending a non-zero return status is to put the
following after you call your perl script:
    if NOT %errorlevel% == 0 goto script_failed 2>nul

However, *do not define* a "script_failed" label. This will cause your
batch file to attempt to go to a non-existant level, at which point the
batch file itself will error out. The "2>nul" prevents the error message
from the missing label from going to STDERR.

You may be tempted to put "exit 1" instead of using this trick, but
don't do that: calling a batch file with "exit" in it will behave as
though you called "exit" from the command prompt, and shut down your
session! Ah, the hilarity never stops with Windows.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Mon Nov 22 20:37:40 2004

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.