Skip to content

Commit 2331b93

Browse files
committed
get most recent fq python vsn given major.minor
1 parent cf434d0 commit 2331b93

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
MAJOR_MINOR=$1
3+
if [ -z "$MAJOR_MINOR" ]; then
4+
echo >&2 'error in param 1 (minor version increment)'
5+
exit 2
6+
else
7+
[[ $MAJOR_MINOR =~ [0-9]+\.[0-9]+ ]] ||\
8+
{ echo >&2 "wrong format for param 1 (need: MAJOR.MINOR e.g. 3.11)"; exit 3; }
9+
fi
10+
11+
url='https://www.python.org/ftp/python/'
12+
13+
# Fetch the directory listing, extract version numbers, sort them, and find the latest 3.$MINOR.x
14+
curl --silent "$url"|\
15+
sed -n 's!.*href="\('$MAJOR_MINOR'\.[0-9]\+\)/".*!\1!p'|sort -rV|\
16+
head -n 1

0 commit comments

Comments
 (0)