You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by "D.J. Heap" <dj...@shadyvale.net> on 2003/08/11 19:31:22 UTC

Hooks on Windows

Hooks on Windows generally seem to work fine.  And as far as I can tell, 
normal program hooks (.exe's) work fine all the time.  However, when 
using .cmd or .bat scripts, the stderr output is not captured correctly. 
  Instead you get something like:

D:\Temp\test\uh2>svn commit -m "test"
Sending        UnmanagedHost.sln
Transmitting file data .svn: A repository hook failed.
svn: Commit failed (details follow):
svn: 'pre-commit' hook failed with error output:
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.

If you were using a pre-commit hook script that does nothing except 
'exit 1'.

If the script calls programs that write to stderr, their output appears 
in the middle and looks fine, like:

D:\Temp\test\uh2>svn commit -m "test"
Sending        UnmanagedHost.sln
Transmitting file data .svn: A repository hook failed.
svn: Commit failed (details follow):
svn: 'pre-commit' hook failed with error output:
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
Blah blah bad commit.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.


I am not a commandline expert, but as I was investigating this I could 
not figure out how to get a script to write to stderr (echo can't seem 
to do it) and I was wondering if maybe scripts don't have stderr on 
Windows (thus all the invalid handle lines which exactly correspond to 
the FormatMessage text of an ERROR_INVALID_HANDLE (6)).

Can someone enlighten me as to how stderr works with scripts on Windows, 
or perhaps confirm that there is no such thing and recommend a strategy 
to deal with it?

DJ




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

Re: Hooks on Windows

Posted by Branko Čibej <br...@xbc.nu>.
D.J. Heap wrote:

> Yes, I remembered you mentioning this a while ago and I did try using
> APR_SHELLCMD, but got the same results -- This is on the call to
> apr_procattr_cmdtype_set in io.c's svn_io_run_cmd function, right?  I
> just hardcoded APR_SHELLCMD for testing here...is something else needed? 

Hm, I'd have thought not. Strange.


-- 
Brane Čibej   <br...@xbc.nu>   http://www.xbc.nu/brane/


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

Re: Hooks on Windows

Posted by "D.J. Heap" <dj...@shadyvale.net>.
Branko Čibej wrote:
> D.J. Heap wrote:
> 
> 
>>Hooks on Windows generally seem to work fine.  And as far as I can
>>tell, normal program hooks (.exe's) work fine all the time.  However,
>>when using .cmd or .bat scripts, the stderr output is not captured
>>correctly.
> 
> 
> This is most probably due to the fact that we don't run batch scripts
> correctly on Windows. We should be using the APR_SHELLCMD to start the
> hook if it's a batch file (see libsvn_repos/hooks.c:run_hook_cmd) --
> this means passing another flag to svn_io_run_cmd. It works just fine on
> Unix because shell scripts are treated the same as executables by the
> kernel. Not so on Windows.... Patches would be welcome. My guess is that
> a flag alongside the file extension in check_hook_cmd could do the trick.
> 
> [snip]


Yes, I remembered you mentioning this a while ago and I did try using 
APR_SHELLCMD, but got the same results -- This is on the call to 
apr_procattr_cmdtype_set in io.c's svn_io_run_cmd function, right?  I 
just hardcoded APR_SHELLCMD for testing here...is something else needed?


> 
> 
>>I am not a commandline expert, but as I was investigating this I could
>>not figure out how to get a script to write to stderr (echo can't seem
>>to do it)
> 
> 
> Heh. Echo can do it, so can anything else. Redirection to stderr is done
> the same way as on Unix: 1>&2. Windows Help is your friend.
> 
> Anyway, fixing the hook execution logic would do the trick, I expect.
> 

Ah, thanks!  I can now get the stderr output in the middle of the 
invalid handle messages...so it seems to be working fine, it just gets 
all the invalid handle message garbage.

DJ


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

Re: Hooks on Windows

Posted by Branko Čibej <br...@xbc.nu>.
D.J. Heap wrote:

> Hooks on Windows generally seem to work fine.  And as far as I can
> tell, normal program hooks (.exe's) work fine all the time.  However,
> when using .cmd or .bat scripts, the stderr output is not captured
> correctly.

This is most probably due to the fact that we don't run batch scripts
correctly on Windows. We should be using the APR_SHELLCMD to start the
hook if it's a batch file (see libsvn_repos/hooks.c:run_hook_cmd) --
this means passing another flag to svn_io_run_cmd. It works just fine on
Unix because shell scripts are treated the same as executables by the
kernel. Not so on Windows.... Patches would be welcome. My guess is that
a flag alongside the file extension in check_hook_cmd could do the trick.

[snip]

> I am not a commandline expert, but as I was investigating this I could
> not figure out how to get a script to write to stderr (echo can't seem
> to do it)

Heh. Echo can do it, so can anything else. Redirection to stderr is done
the same way as on Unix: 1>&2. Windows Help is your friend.

Anyway, fixing the hook execution logic would do the trick, I expect.

-- 
Brane Čibej   <br...@xbc.nu>   http://www.xbc.nu/brane/


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