Skip to content

Commit

Permalink
Fix shellcheck smells
Browse files Browse the repository at this point in the history
  • Loading branch information
sbmueller committed Dec 10, 2024
1 parent bfce9a9 commit ea8076f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions clang_format/run_clang_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
set -ue

format_all() {
CLANG_FORMAT_CONFIG=$(realpath $1)
CLANG_FORMAT_CONFIG=$(realpath "$1")

cd $BUILD_WORKSPACE_DIRECTORY
cd "$BUILD_WORKSPACE_DIRECTORY"
git ls-files '*.[ch]' '*.cpp' '*.cxx' '*.cc' '*.hpp' '*.hxx' \
| xargs -r $CLANG_FORMAT_BIN -i --style=file:$CLANG_FORMAT_CONFIG
| xargs -r "$CLANG_FORMAT_BIN" -i --style=file:"$CLANG_FORMAT_CONFIG"
}

format_diff() {
CLANG_FORMAT_CONFIG=$(realpath $1)
CLANG_FORMAT_CONFIG=$(realpath "$1")

cd $BUILD_WORKSPACE_DIRECTORY
cd "$BUILD_WORKSPACE_DIRECTORY"
git describe --tags --abbrev=0 --always \
| xargs -rI % git diff --diff-filter=ACMRTUXB --name-only --line-prefix=`git rev-parse --show-toplevel`/ % -- '*.[ch]' '*.cpp' '*.cxx' '*.cc' '*.hpp' '*.hxx' \
| xargs -r $CLANG_FORMAT_BIN -i --style=file:$CLANG_FORMAT_CONFIG
| xargs -rI % git diff --diff-filter=ACMRTUXB --name-only --line-prefix="$(git rev-parse --show-toplevel)"/ % -- '*.[ch]' '*.cpp' '*.cxx' '*.cc' '*.hpp' '*.hxx' \
| xargs -r "$CLANG_FORMAT_BIN" -i --style=file:"$CLANG_FORMAT_CONFIG"
}

check_file() {
Expand All @@ -28,14 +28,14 @@ check_file() {

# .clang-format config file has to be placed in the current working directory
if [ ! -f ".clang-format" ]; then
ln -s $CONFIG .clang-format
ln -s "$CONFIG" .clang-format
fi

$CLANG_FORMAT_BIN $INPUT --dry-run -Werror > $OUTPUT
$CLANG_FORMAT_BIN "$INPUT" --dry-run -Werror > "$OUTPUT"
}

ARG=$1
CLANG_FORMAT_BIN=$(realpath $2)
CLANG_FORMAT_BIN=$(realpath "$2")
shift 2

if [ "$ARG" == "format_diff" ]; then
Expand Down

0 comments on commit ea8076f

Please sign in to comment.