Skip to content

Commit 62cf4dd

Browse files
committed
allow between 0 and 3 dot-separated numbers in python versiono
1 parent 5635187 commit 62cf4dd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

irods/test/harness/most_recent_python.sh

100644100755
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ usage() {
77
exit 2
88
}
99
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
1117
usage
1218
fi
1319

1420
url='https://www.python.org/ftp/python/'
1521

1622
# Fetch the directory listing, extract version numbers, sort them to find the largest numerically.
1723
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|\
1925
head -n 1

0 commit comments

Comments
 (0)