2
2
3
3
set -e
4
4
5
- script_folder=` dirname $0 `
6
- absolute_repository_root=` git rev-parse --show-toplevel`
5
+ script_folder=$( dirname " $0 " )
6
+ absolute_repository_root=$( git rev-parse --show-toplevel)
7
7
mode=$1
8
8
modes=" CPPLINT | DOXYGEN"
9
9
16
16
exit 1
17
17
fi
18
18
19
- if ! [[ -e $script_folder /filter_by_lines.py ]]
19
+ if ! [[ -e ${ script_folder} /filter_by_lines.py ]]
20
20
then
21
21
echo " Filter script could not be found in the $script_folder directory"
22
22
echo " Ensure filter_by_lines.py is inside the $script_folder directory then run again"
31
31
exit 1
32
32
fi
33
33
34
- if ! [[ -e $ script_folder /cpplint.py ]]
34
+ if ! [[ -e " ${ script_folder} /cpplint.py" ]]
35
35
then
36
36
echo " Lint script could not be found in the $script_folder directory"
37
37
echo " Ensure cpplint.py is inside the $script_folder directory then run again"
38
38
exit 1
39
39
else
40
- cmd=' $script_folder/cpplint.py $file 2>&1 >/dev/null'
40
+ cmd=' ${ script_folder} /cpplint.py $file 2>&1 >/dev/null'
41
41
fi
42
42
elif [[ " $mode " == " DOXYGEN" ]]
43
43
then
78
78
git_merge_base_end=" HEAD"
79
79
fi
80
80
81
- git_start=` git merge-base $git_start $git_merge_base_end `
81
+ git_start=$( git merge-base $git_start $git_merge_base_end )
82
82
83
83
cleanup ()
84
84
{
85
- rm -f $diff_file $added_lines_file
85
+ rm -f " $diff_file " " $added_lines_file "
86
86
}
87
87
88
88
trap cleanup EXIT
89
89
90
- diff_file=` mktemp`
91
- added_lines_file=` mktemp`
90
+ diff_file=$( mktemp)
91
+ added_lines_file=$( mktemp)
92
92
93
93
# Pass the output through iconv to remove any invalid UTF-8 (diff_to_added_lines.py will die otherwise)
94
94
95
- git diff $git_start $git_end | iconv -t utf-8 -c > $diff_file
95
+ git diff $git_start $git_end | iconv -t utf-8 -c > " $diff_file "
96
96
97
97
# Get the list of files that have changed, that end with lintable extensions
98
- diff_files=` git diff --name-only $git_start $git_end | grep " \.\(\(cpp\)\|\(hh\)\|\(cc\)\|h\)$" || true`
98
+ diff_files=$( git diff --name-only $git_start $git_end | grep " \.\(\(cpp\)\|\(hh\)\|\(cc\)\|h\)$" || true)
99
99
100
- $ script_folder /diff_to_added_lines.py $diff_file $absolute_repository_root > $added_lines_file
100
+ " ${ script_folder} /diff_to_added_lines.py" " $diff_file " " $absolute_repository_root " > " $added_lines_file "
101
101
102
102
for file in $diff_files ; do
103
103
file=$absolute_repository_root /$file
@@ -109,7 +109,7 @@ for file in $diff_files; do
109
109
110
110
# Run the linting script and filter:
111
111
# The errors from the linter go to STDERR so must be redirected to STDOUT
112
- result=` eval $cmd | $ script_folder/filter_by_diff .py $file $added_lines_file $absolute_repository_root `
112
+ result=$( eval $cmd | " ${ script_folder} /filter_by_lines .py" " $file " " $added_lines_file " " $absolute_repository_root " )
113
113
114
114
# Providing some errors were relevant we print them out
115
115
if [ " $result " ]
0 commit comments