Skip to content

Commit 4edf684

Browse files
committed
Ditch "tac|tac" for more reliable scraping
1 parent 2ffc9e1 commit 4edf684

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

versions.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ for version in "${versions[@]}"; do
3838
if \
3939
{
4040
versionReleasePage="$(grep "<td>Ruby $tryVersion</td>" -A 2 <<<"$releasesPage" | awk -F '"' '$1 == "<td><a href=" { print $2; exit }')" \
41-
&& [ "$versionReleasePage" ] \
42-
&& shaVal="$(curl -fsSL "https://www.ruby-lang.org/$versionReleasePage" |tac|tac| grep "ruby-$tryVersion.tar.xz" -A 5 | awk '$1 == "SHA256:" { print $2; exit }')" \
43-
&& [ "$shaVal" ]
41+
&& [ -n "$versionReleasePage" ] \
42+
&& shaVal="$(curl -fsSL "https://www.ruby-lang.org/$versionReleasePage" | grep "ruby-$tryVersion.tar.xz" -A 5)" \
43+
&& shaVal="$(awk <<<"$shaVal" '$1 == "SHA256:" { print $2; exit }')" \
44+
&& [ -n "$shaVal" ]
4445
} \
4546
|| {
4647
versionReleasePage="$(echo "$newsPage" | grep -oE '<a href="[^"]+">Ruby '"$tryVersion"' Released</a>' | cut -d'"' -f2)" \
47-
&& [ "$versionReleasePage" ] \
48-
&& shaVal="$(curl -fsSL "https://www.ruby-lang.org/$versionReleasePage" |tac|tac| grep "ruby-$tryVersion.tar.xz" -A 5 | awk '$1 == "SHA256:" { print $2; exit }')" \
49-
&& [ "$shaVal" ]
48+
&& [ -n "$versionReleasePage" ] \
49+
&& shaVal="$(curl -fsSL "https://www.ruby-lang.org/$versionReleasePage" | grep "ruby-$tryVersion.tar.xz" -A 5)" \
50+
&& shaVal="$(awk <<<"$shaVal" '$1 == "SHA256:" { print $2; exit }')" \
51+
&& [ -n "$shaVal" ]
5052
} \
5153
; then
5254
fullVersion="$tryVersion"

0 commit comments

Comments
 (0)