File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,19 @@ usage() {
7
7
exit 2
8
8
}
9
9
MAJOR_MINOR=$1
10
- if ! [[ $MAJOR_MINOR =~ [0-9]+\. [0-9]+ ]]; then
10
+ if [ -z " ${MAJOR_MINOR} " ]; then # allow blank specification: most recent overall
11
+ MAJOR_MINOR=' [0-9]\+\.[0-9]\+'
12
+ elif [[ $MAJOR_MINOR =~ ^[0-9]+$ ]]; then # allow single integer, eg. 3 for most recent 3.y.z
13
+ MAJOR_MINOR+=' \.[0-9]\+'
14
+ elif [[ $MAJOR_MINOR =~ [0-9]+\. [0-9]+ ]]; then # allow x.y form, will yield output of most recent x.y.z
15
+ MAJOR_MINOR=$( sed ' s/\./\\./' <<< " ${MAJOR_MINOR}" ) # insert backslash in front of "."
16
+ elif ! [[ $MAJOR_MINOR =~ [0-9]+\\ ? .[0-9]+ ]]; then
11
17
usage
12
18
fi
13
19
14
20
url=' https://www.python.org/ftp/python/'
15
21
16
22
# Fetch the directory listing, extract version numbers, sort them to find the largest numerically.
17
23
curl --silent " $url " | \
18
- sed -n ' s!.*href="\(' ${MAJOR_MINOR} ' \.[0-9]\+\)/".*!\1!p' | sort -rV| \
24
+ sed -n ' s!.*href="\(' " ${MAJOR_MINOR} " ' \.[0-9]\+\)/".*!\1!p' | sort -rV| \
19
25
head -n 1
You can’t perform that action at this time.
0 commit comments