aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorAkio Nakamura <nakamura@dgtechnologies.co.jp>2018-03-01 16:03:38 +0900
committerAkio Nakamura <nakamura@dgtechnologies.co.jp>2018-03-01 16:03:38 +0900
commit0fbed98e4202bb458466791e83e4e2fb25250d51 (patch)
treec50ae223fddcf4c56e9a842c26ba63b04f300fb2 /contrib
parent9e2ed253f50500e1db4927d511d3ac0d47aed8df (diff)
downloadbitcoin-0fbed98e4202bb458466791e83e4e2fb25250d51.tar.xz
[script] lint-whitespace: improve print linenumber
Before this PR, the linenumber infomaition is output if trailing-space or tab code was found, but the output occurence is only per a file. This PR separates the output timing of file name and line number. As a result, users will find where they need to fix more easily.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/devtools/lint-whitespace.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/contrib/devtools/lint-whitespace.sh b/contrib/devtools/lint-whitespace.sh
index af9a57910a..877fa00d43 100755
--- a/contrib/devtools/lint-whitespace.sh
+++ b/contrib/devtools/lint-whitespace.sh
@@ -37,21 +37,26 @@ if showdiff | grep -E -q '^\+.*\s+$'; then
echo "The following changes were suspected:"
FILENAME=""
SEEN=0
+ SEENLN=0
while read -r line; do
if [[ "$line" =~ ^diff ]]; then
FILENAME="$line"
SEEN=0
elif [[ "$line" =~ ^@@ ]]; then
LINENUMBER="$line"
+ SEENLN=0
else
if [ "$SEEN" -eq 0 ]; then
# The first time a file is seen with trailing whitespace, we print the
# filename (preceded by a newline).
echo
echo "$FILENAME"
- echo "$LINENUMBER"
SEEN=1
fi
+ if [ "$SEENLN" -eq 0 ]; then
+ echo "$LINENUMBER"
+ SEENLN=1
+ fi
echo "$line"
fi
done < <(showdiff | grep -E '^(diff --git |@@|\+.*\s+$)')
@@ -64,21 +69,26 @@ if showcodediff | grep -P -q '^\+.*\t'; then
echo "The following changes were suspected:"
FILENAME=""
SEEN=0
+ SEENLN=0
while read -r line; do
if [[ "$line" =~ ^diff ]]; then
FILENAME="$line"
SEEN=0
elif [[ "$line" =~ ^@@ ]]; then
LINENUMBER="$line"
+ SEENLN=0
else
if [ "$SEEN" -eq 0 ]; then
# The first time a file is seen with a tab character, we print the
# filename (preceded by a newline).
echo
echo "$FILENAME"
- echo "$LINENUMBER"
SEEN=1
fi
+ if [ "$SEENLN" -eq 0 ]; then
+ echo "$LINENUMBER"
+ SEENLN=1
+ fi
echo "$line"
fi
done < <(showcodediff | grep -P '^(diff --git |@@|\+.*\t)')