From db37321fb23dfe7c257956b2d344e3642d3769ee Mon Sep 17 00:00:00 2001 From: taoky Date: Mon, 22 Jan 2024 15:44:41 +0800 Subject: [PATCH] break while loop when next_page is empty --- common.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common.sh b/common.sh index e06be87..84870b7 100755 --- a/common.sh +++ b/common.sh @@ -8,8 +8,11 @@ docker-tags(){ return 1 fi grep -oP '(?<="name":").+?(?=")' <(echo "$tags_js") - while next_page=$(grep -oP '(?<="next":").+?(?=")' <(echo "$tags_js") | sed 's/\\u0026/\&/' ) + while next_page=$(grep -oP '(?<="next":").+?(?=")' <(echo "$tags_js") | sed 's/\\u0026/\&/' | xargs) do + if [[ -z "$next_page" || "$next_page" == "null" ]]; then + break + fi tags_js=$(curl -sSL "$next_page") if [ $? -ne 0 ]; then echo "curl $next_page failed" >&2