Skip to content

Commit

Permalink
break while loop when next_page is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Jan 22, 2024
1 parent 737809a commit db37321
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit db37321

Please sign in to comment.