From 419d7e8a94790a44abb40a77c2b3d1358da23d0c Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Tue, 4 Jun 2024 13:06:55 +0200 Subject: [PATCH] Update link checker script to produce more readable output --- .github/helpers/check_urls.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/helpers/check_urls.sh b/.github/helpers/check_urls.sh index 81f73ea7..2bccc8d7 100755 --- a/.github/helpers/check_urls.sh +++ b/.github/helpers/check_urls.sh @@ -7,17 +7,21 @@ urls=$(grep -oP "(http|ftp|https):\/\/([a-zA-Z0-9_-]+(?:(?:\.[a-zA-Z0-9_-]+)+))( fail_counter=0 +FAILED_LINKS=() for item in $urls; do # echo $item filename=$(echo "$item" | cut -d':' -f1) url=$(echo "$item" | cut -d':' -f2-) - echo "Checking $url from file $filename" + echo -n "Checking $url from file $filename" if ! curl --head --silent --fail "$url" 2>&1 > /dev/null; then - echo "Invalid link in file $filename: $url" + echo -e " \033[0;31mNOT FOUND\033[32m\n" + FAILED_LINKS+=("$url from file $filename") ((fail_counter=fail_counter+1)) else - echo "$url ok" + printf " \033[32mok\033[0m\n" fi done +echo "Failed files:" +printf '%s\n' "${FAILED_LINKS[@]}" exit $fail_counter