From 14b49b4b210bab1812a0411d71da26ff0f4e996e Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Mon, 5 Jun 2023 15:52:45 +0200 Subject: [PATCH] check for existence of opkg_commands-file --- .githooks/post-checkout | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.githooks/post-checkout b/.githooks/post-checkout index a381e6c..7414cab 100755 --- a/.githooks/post-checkout +++ b/.githooks/post-checkout @@ -27,16 +27,18 @@ write_log_file () { echo "DOWNLOAD, /etc/psa_config/DC2C_print29.json, $now, N/A" >> $GIT_UPDATE_LOG echo "DOWNLOAD, /etc/psa_config/DC2C_print32.json, $now, N/A" >> $GIT_UPDATE_LOG if grep -qE . "${OPKG_COMMANDS_FILE}"; then - readarray opkg_commands < <(cat $OPKG_COMMANDS_FILE) - for opkg_c in "${opkg_commands[@]}"; do - # check for lines longer than 'opkg ' - if [ "${#opkg_c}" -gt 4 ]; then - # comment: spaces, at least one '#' - grep -qE '^[[:space:]]*#+.*$' <<< "$opkg_c" && continue - echo -n "EXECUTE, $opkg_c, $now, N/A" | tr -d '\n\r' >> $GIT_UPDATE_LOG 2>&1 - echo "" >> $GIT_UPDATE_LOG 2>&1 - fi - done + if [ -f "$OPKG_COMMANDS_FILE" ]; then + readarray opkg_commands < <(cat $OPKG_COMMANDS_FILE) + for opkg_c in "${opkg_commands[@]}"; do + # check for lines longer than 'opkg ' + if [ "${#opkg_c}" -gt 4 ]; then + # comment: spaces, at least one '#' + grep -qE '^[[:space:]]*#+.*$' <<< "$opkg_c" && continue + echo -n "EXECUTE, $opkg_c, $now, N/A" | tr -d '\n\r' >> $GIT_UPDATE_LOG 2>&1 + echo "" >> $GIT_UPDATE_LOG 2>&1 + fi + done + fi fi else echo "Found existing line: $line. Do nothing"