[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: Jason Butlin <roguejay_at_hotmail.com>
Date: 2004-11-23 09:05:10 CET

>From: Toby Johnson <toby@etjohnson.us>
>Reply-To: users@subversion.tigris.org
>To: Jason Butlin <roguejay@hotmail.com>
>CC: users@subversion.tigris.org
>Subject: Re: Hooks and Perl on Windows
>Date: Mon, 22 Nov 2004 14:35:04 -0500
>
>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.

Interesting point about not calling exit, which is what I do - and seems to
work O.K. I might change it anyway.

My problem lies in the fact that after calling the Perl scrip %errorlevel%
will ALWAYS be equal to 0, no matter what the Perl script exits with. But if
I run the batch file from the command line, the after the Perl script the
errorlevel is correctly 0 or 1.

Jay

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Tue Nov 23 17:18:02 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.