Skip to content

Commit

Permalink
formatted astyle.sh + removed shellcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Iximiel committed Sep 19, 2024
1 parent 5b31d29 commit 91e9329
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions src/astyle.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
#! /usr/bin/env bash

#formatted with shfmt v3.6.0
DIRS=$1

# keep only dirname
DIRS=${DIRS##*/}
echo "$DIRS"

# shellcheck disable=SC2125
test -z "$DIRS" && DIRS=*

for dir in $DIRS
do
test -d "$dir" || continue

test "$dir" = lapack && continue
test "$dir" = blas && continue
test "$dir" = molfile && continue
test "$dir" = lepton && continue
test "$dir" = asmjit && continue
test "$dir" = xdrfile && continue
for dir in $DIRS; do
test -d "$dir" || continue

cd $dir
test "$dir" = lapack && continue
test "$dir" = blas && continue
test "$dir" = molfile && continue
test "$dir" = lepton && continue
test "$dir" = asmjit && continue
test "$dir" = xdrfile && continue

cd "$dir" || {
echo "Problem with 'cd $dir'"
exit 1
}

for file in *.c *.cpp *.h *.inc.in
do
for file in *.c *.cpp *.h *.inc.in; do

test -f "$file" || continue
test -f "$file" || continue

echo -n "astyle $file"
echo -n "astyle $file"

../../astyle/astyle --options=../../.astyle.options < $file > $file.tmp && {
if cmp -s $file $file.tmp ; then
echo
else
cp $file.tmp $file
echo " +++ PATCHED"
git add $file
fi
}
../../astyle/astyle --options=../../.astyle.options <"$file" >"$file.tmp" && {
if cmp -s "$file" "$file.tmp"; then
echo
else
cp "$file.tmp" "$file"
echo " +++ PATCHED"
git add "$file"
fi
}

rm $file.tmp
rm "$file.tmp"

done
done

cd -
cd - || {
echo "Problem with 'cd -' from '$dir'"
exit 1
}

done


0 comments on commit 91e9329

Please sign in to comment.