I'm writing a post-commit script in bash, and I'd like to pass messages back to the client who's making a commit. However
echo my message >&2
isn't making it back to the client. Is it even possible to send messages back with a post-commit hook?
I'm writing a post-commit script in bash, and I'd like to pass messages back to the client who's making a commit. However
echo my message >&2
isn't making it back to the client. Is it even possible to send messages back with a post-commit hook?
Condering a post-commit hook does:
anything that the hook printed to stderr will be marshalled back to the client, making it easier to diagnose hook failures.
you can check if this isn't a simple quote issue:
echo "my message" >&2
You can see in those hook examples that any echo
to >&2
includes quotes.
The bash chapter on redirection also includes examples with quotes.
However, as pmod details in his answer, that stderr message won't be visible unless the exit status of the script differs from 0, as illustrated in "subversion post-commit hook: print an error message that the user can see?"
#!/bin/bash
echo "test" >&2
exit 1
Hook will show STDERR only if it fails (and as you may now, hook doesn't display STDOUT). Thus, you have to return non-zero code from your script to pass "my message" to user (just add exit 1 after echo).
Take a look here:
If the post-commit hook returns a nonzero exit status, the commit will not be aborted since it has already completed. However, anything that the hook printed to stderr will be marshalled back to the client, making it easier to diagnose hook failures.
Condering a post-commit hook does:
anything that the hook printed to stderr will be marshalled back to the client, making it easier to diagnose hook failures.
you can check if this isn't a simple quote issue:
echo "my message" >&2
You can see in those hook examples that any echo
to >&2
includes quotes.
The bash chapter on redirection also includes examples with quotes.
However, as pmod details in his answer, that stderr message won't be visible unless the exit status of the script differs from 0, as illustrated in "subversion post-commit hook: print an error message that the user can see?"
#!/bin/bash
echo "test" >&2
exit 1
I had the same problem, with Apache and mod_svn. It turned out that the marshalling fails when the text being marshalled contained &
, <
or >
characters. After substituting them with &
, <
and >
the text got through.
© 2022 - 2024 — McMap. All rights reserved.