[LLVMdev] svn pre-commit hook: help needed

Misha Brukman brukman at gmail.com
Fri Feb 20 15:18:02 PST 2009


2009/2/20 Scott Michel <scottm at aero.org>

> On Feb 20, 2009, at 12:45 PM, Misha Brukman wrote:
> I've got a fairly simple perl script that trims trailing whitespace [...]
>

% cat llvm/utils/lint/remove_trailing_whitespace.sh
#!/bin/sh
# Deletes trailing whitespace in-place in the passed-in files.
# Sample syntax:
#   $0 *.cpp

perl -pi -e 's/\s+$/\n/' $*

Yep, it's a one-liner.


> [...] and it's remarkably effective. It even works over recursive
> directories (not hard to do, but it's the way to do this globally.)


With recursion into subdirectories:

% remove_trailing_whitespace.sh `find . -name \*\.h`


> I'm sure it's not too much of a stretch to translate tabs to spaces,
> although that's controversial.


Good point, I should add a verifier to the lint tool to check for tabs in
non-Makefiles.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090220/c9cada97/attachment.html>


More information about the llvm-dev mailing list