arch-pkgs/.repo/pkgver/html-xml-utils.sh
George Rawlinson db2ecb84e0
nvchecker: add external scripts
Something is wrong with .gitignore, these scripts were not being added
previously.

*shoots .gitignore*
2021-07-24 12:58:02 +00:00

33 lines
739 B
Bash
Executable file

#!/bin/bash
set -e
# check dependencies
count=0
for dependency in hxnormalize hxselect grep sed sort tail; do
if [ ! -x "$(command -v $dependency)" ]; then
echo "$dependency missing"
count=$((count+1))
fi
done
# exit script if any dependencies missing
if [ $count -ne 0 ]; then
exit 1
fi
# upstream URL
UPSTREAM_URL="https://www.w3.org/Tools/HTML-XML-utils/"
# options to pass to cURL, including custom user agent
USER_AGENT="hxu-version-checker/1.0 george@rawlinson.net.nz"
CURL_OPTS=(--silent --user-agent "$USER_AGENT")
curl "${CURL_OPTS[@]}" "$UPSTREAM_URL" | \
hxnormalize -x | \
hxselect -c 'a' -s '\n' | \
grep "html-xml-utils" | \
sed -e "s/html-xml-utils-//g" -e "s/.tar.gz//g" | \
sort -n | \
tail -n 1
exit 0