# hooks--pre-commit: chomp() in cygwin perl does not strip "\r"

1 messages from 2006-10-20 to 2006-10-20. Participants: Liu Yubao.
Thread: https://gitlist.dev/t/5961

## Liu Yubao, 2006-10-20 06:14

Subject: hooks--pre-commit: chomp() in cygwin perl does not strip "\r"
Message-ID: <4538692E.6030404@gmail.com>
URL: https://gitlist.dev/e/4538692E.6030404%40gmail.com

```
perl v5.8.7 built for cygwin-thread-multi-64int, its chomp() doesn't strip
trailing "\r" so that pre-commit reports "trailing whitespace" for every line.
ActiveState Perl v5.8.8 can strip "\r" and "\n" properly.

Changing
	if (/\s$/) {
to
	if (/[:blank:]$/) {
is also ok.

diff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit
index 723a9ef..6a55612
--- a/templates/hooks--pre-commit
+++ b/templates/hooks--pre-commit
@@ -54,7 +54,7 @@ perl -e '
         }
         if (s/^\+//) {
             $lineno++;
-           chomp;
+           s/[\r\n]+$//;
             if (/\s$/) {
                 bad_line("trailing whitespace", $_);
             }

```
