From 3a7adca8d2fb27a32b3443c5f6b3cb5db908c0ed Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Mon, 22 Jul 2019 18:22:37 +0200 Subject: [PATCH] fix(code-style.sh): Warn on non-C files Signed-off-by: Rahix <rahix@rahix.de> --- tools/code-style.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/code-style.sh b/tools/code-style.sh index b18533bd..2d459c57 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 -- GitLab