Avoid rewriting the same file multiple times

Also process some more extensions that current source files use.
This commit is contained in:
Gunter Labes 2024-07-30 20:43:14 +02:00
parent 0bb7395804
commit 8c581eee90
No known key found for this signature in database
GPG Key ID: C0C7B971CC910216

View File

@ -1,16 +1,14 @@
#!/bin/bash #!/bin/sh
OS="$(uname -s)"
make -C data/tools reindent make -C data/tools reindent
if [[ "$OS" == "Linux" ]]; then # use -i for GNU sed and -i '' otherwise
find src/ -not -path "src/modules/*" -name \*.\[ch\]pp -print0 | xargs -0 sed -i -e '$a\' sed --version 2>/dev/null | grep -q 'GNU sed' || i=1
find src/ -not -path "src/modules/*" -name \*.\[ch\]pp -print0 | xargs -0 sed -i 's/[[:blank:]]*$//'
find data/ -name \*.lua -print0 | xargs -0 sed -i 's/[[:blank:]]*$//'
else
find src/ -not -path "src/modules/*" -name \*.\[ch\]pp -print0 | xargs -0 sed -i '' 's/[[:blank:]]*$//'
find data/ -name \*.lua -print0 | xargs -0 sed -i '' 's/[[:blank:]]*$//'
fi
find data/ -name \*.lua -print0 | xargs -0 data/tools/check_mixed_indent find src -path src/modules -prune -o \
\( -name '*.[cht]pp' -o -name '*.[ch]' -o -name '*.mm' \) -type f \
-exec sed -i ${i:+''} -e 's/[[:blank:]]*$//' -e '$a\' {} +
find data -name '*.lua' -type f \
-exec sed -i ${i:+''} -e 's/[[:blank:]]*$//' -e '$a\' {} + \
-exec data/tools/check_mixed_indent {} +