Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add shell script formatting #182

Merged
merged 4 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/shellformatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: run shell formatting on scripts

"on":
push:
branches:
- main
- devel
pull_request:


jobs:
build:
name: Runs shell formatting on scripts
runs-on: ubuntu-24.04

steps:
- name: checkout
uses: actions/checkout@v4
- name: install packages
run: sudo apt install shfmt
- name: run fmtsh
run: ./do_shellfmt.sh
- name: check diff
run: |
git diff |tee shellfmt.patch
if ! git diff-index --quiet HEAD ; then
echo "please run ./do_shellfmt.sh";
exit 1;
fi
- name: store diff as an artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
path: 'shellfmt.patch'
8 changes: 4 additions & 4 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ set -e
me="$(basename "$0")"

for prog in aclocal autoheader automake autoconf make; do
if ! which $prog >/dev/null 2>&1 ; then
echo "$me: please install $prog"
exit 1
fi
if ! which $prog >/dev/null 2>&1; then
echo "$me: please install $prog"
exit 1
fi
done

aclocal --warnings=all
Expand Down
7 changes: 2 additions & 5 deletions cppcheck/run_cppcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ cppcheck $args --xml ./*.cc ./*.hh 2>"$outdir/cppcheck.xml"

cppcheck-htmlreport --source-dir=. --title=rdfind --file="$outdir/cppcheck.xml" --report-dir="$outdir"


#is anything serious found?
if grep --quiet -v -E '^(style|information|performance):' "$outdir/cppcheck.out"; then
echo "$me: cppcheck found serious issues. see $outdir/cppcheck.out"
exit 1
echo "$me: cppcheck found serious issues. see $outdir/cppcheck.out"
exit 1
fi

echo "$me: cppcheck passed without serious issues."


14 changes: 7 additions & 7 deletions do_clang_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
# See LICENSE for further details.

#find clang format (usually named clang-format-3.x or clang-format, who knows)
CLANGFORMAT="$(find /usr/local/bin /usr/bin -executable -name "clang-format*" |grep -v -- -diff |sort -g |tail -n1)"
CLANGFORMAT="$(find /usr/local/bin /usr/bin -executable -name "clang-format*" | grep -v -- -diff | sort -g | tail -n1)"

if [ ! -x "$CLANGFORMAT" ] ; then
echo "failed finding clangformat"
exit 1
if [ ! -x "$CLANGFORMAT" ]; then
echo "failed finding clangformat"
exit 1
else
echo "found clang format: $CLANGFORMAT"
echo "found clang format: $CLANGFORMAT"
fi

find . -maxdepth 1 -type f \( -name "*.h" -o -name "*.cpp" -o -name "*.cc" -o -name "*.hh" \) -print0 | \
xargs -0 -n1 "$CLANGFORMAT" -i
find . -maxdepth 1 -type f \( -name "*.h" -o -name "*.cpp" -o -name "*.cc" -o -name "*.hh" \) -print0 \
| xargs -0 -n1 "$CLANGFORMAT" -i
Loading
Loading