-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.sh
43 lines (38 loc) · 965 Bytes
/
env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# apply astyle to all CPP files of the project
astyle-apply () {
local root_dir
root_dir="$(git rev-parse --show-toplevel)"
find \
"$root_dir" \
-regex ".*\.\(hpp\|cpp\)" \
-not -path "*/build/*" \
-not -path "*/doc/*" \
-exec astyle --options="$root_dir/.astylerc" {} \;
}
# check all CPP files of the project with astyle
astyle-check () {
local root_dir
local ok=0
local list
root_dir="$(git rev-parse --show-toplevel)"
list=$(find \
"$root_dir" \
-regex ".*\.\(hpp\|cpp\)" \
-not -path "*/build/*" \
-not -path "*/doc/*" \
-print0 \
)
while read -rd $'\0' file
do
if ! astyle --options="$root_dir/.astylerc" <"$file" | cmp -s "$file"
then
echo "Would format $file"
ok=1
fi
done <<<"$list"
if [[ $ok == "0" ]]
then
echo "All files formatted"
fi
return $ok
}