RE: Help with post-commit script
From: Andrew Reedick <Andrew.Reedick_at_cbeyond.net>
Date: Tue, 3 Dec 2013 15:04:13 -0500
> -----Original Message-----
Close. Read will drop leading/trailing whitespace. It does respect "internal" whitespace though.
The fix is to set IFS to null:
Now if someone has embedded newlines in their filenames then that would be a problem. At that point you're talking about 'xargs -0 (--null)', sort -z, (--zero-terminated), using perl to chomp the newline and output a null character, etc. How does 'svnlook changed' output filenames with embedded newlines anyway?
>
The entries in the filelist svn property would need to be in a regex format. So everything would be escaped already.
If not, then perl's quotemeta and greps --fixed-strings flags would be of use: perl -ne 'chomp; print quotemeta($_) . "\n"' file.txt.
Anyway, IME, it's almost always a better idea to use the --xml option when parsing svn commands, which implies writing a proper perl script. The work can (probably) be done in bash, but with all the whitespace handling and potentially multiple layers of interpolation going on, the code can get unwieldy quickly.
Updated script:
#!/bin/bash
set -o pipefail
REPOS_PATH=$1
SVNLOOK_CMD=/path/to/svnlook
RECIPIENT_LIST=$($SVNLOOK_CMD propget ... my:email_list_prop)
CHANGED_LIST=$(mktemp ...)
$SVNLOOK_CMD changed ... | perl -ne 'chomp; print quotemeta($_) . "\n"' > $CHANGED_LIST || exit 1
perl -i -pe 's/^....//' $CHANGED_LIST
cat $CHANGED_LIST | while read i
|
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.