diff --git a/tools/code-style.sh b/tools/code-style.sh index b18533bdf16129f5e6e9ed38ae2bc7ffa69b09f3..2d459c575b1e74a8d11e6bbc10b783083ba3e74f 100755 --- a/tools/code-style.sh +++ b/tools/code-style.sh @@ -12,7 +12,7 @@ if ! command -v python3 >/dev/null 2>&1; then exit 127 fi -if [ "$#" == 0 ]; then +if [[ "$#" == 0 ]]; then echo "usage: $0 <source.c> ..." exit 1 fi @@ -20,7 +20,12 @@ fi script_dir="$(dirname "$0")" for source_file in "$@"; do - echo "Formatting $source_file ..." - clang-format -i "$source_file" - python3 "$script_dir/fix-multi-decl.py" "$source_file" + if [[ "$source_file" == *.c ]]; then + echo "Formatting $source_file ..." + clang-format -i "$source_file" + python3 "$script_dir/fix-multi-decl.py" "$source_file" + else + echo "Not a C file: $source_file" >&2 + continue + fi done