From 050deba0bdee90c85ff61694d820fcb9fbdb3456 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 25 May 2023 16:54:25 +0200 Subject: [PATCH] test for syntax errors --- .githooks/post-checkout | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.githooks/post-checkout b/.githooks/post-checkout index 3107808..bfcad4e 100755 --- a/.githooks/post-checkout +++ b/.githooks/post-checkout @@ -29,15 +29,14 @@ if [ -f $CHECKOUT_HISTORY_FILE ]; then if grep -q . "${OPKG_COMMANDS_FILE}"; then readarray opkg_commands < <(cat $OPKG_COMMANDS_FILE) for opkg_c in "${opkg_commands[@]}"; do - if [ -z "$opkg_c" ]; then - continue + # check for empty lines + if [ -n "$opkg_c" ]; then + # check if line is not starting with '#' + if ! grep -qE "^\s*[#]+.*$" <<< "$opkg_c"; then + echo -n "EXECUTE, $opkg_c, $now, N/A" | tr -d '\n\r' >> $GIT_UPDATE_LOG 2>&1 + echo "" >> $GIT_UPDATE_LOG 2>&1 + fi fi - next_line=$(grep -E "^\s*[#]+.*$" <<< "$opkg_c") - if ! [ -z "$next_line" ]; then - continue - fi - echo -n "EXECUTE, $opkg_c, $now, N/A" | tr -d '\n\r' >> $GIT_UPDATE_LOG 2>&1 - echo "" >> $GIT_UPDATE_LOG 2>&1 done fi else