Scripts: Add optional 'fix' argument to test-ocp-indent.sh

the script can be called with fix as argument to fix all indentation
problems in one go
This commit is contained in:
Pietro Abate 2017-11-14 11:53:16 +01:00 committed by Benjamin Canou
parent 102ba49149
commit 0f467c263b

View File

@ -1,7 +1,8 @@
#!/bin/sh
#!/bin/bash
tmp_dir="$(mktemp -d -t tezos_build.XXXXXXXXXX)"
failed=no
fix=${1:-""}
for f in ` find \( -name _build -or \
-name .git -or \
@ -12,7 +13,12 @@ for f in ` find \( -name _build -or \
ocp-indent $f > $tmp_dir/$ff
diff -U 3 $f $tmp_dir/$ff
if [ $? -ne 0 ]; then
if [ $fix = "fix" ]; then
echo "Fix indentation $f"
cp $tmp_dir/$ff $f
else
failed=yes
fi
fi
rm -f $tmp_dir/$ff $tmp_dir/$ff.diff
done