Skip to content

Commit a5fa4bd

Browse files
committed
Fix version comparison
1 parent 2b9d304 commit a5fa4bd

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

avc-version

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,36 @@ case "$1" in
2626
echo -n "setup.py: "
2727
grep version setup.py
2828
) | awk "
29-
BEGIN { FS = \"[=:]+\"; max=-1 };
30-
{ gsub(/[,' ]+/, \"\", \$NF); files[NR]=\$1; v=\$NF; versions[NR]=v; if (v > max) max=v;}
29+
function version_to_number(v) {
30+
n = split(v, a, \".\");
31+
r = 0;
32+
for (j=n; j>0; j--) {
33+
r += a[j] * 1000**(n-j);
34+
}
35+
return r;
36+
}
37+
38+
BEGIN {
39+
FS = \"[=:]+\"; max=-1
40+
}
41+
42+
{
43+
gsub(/[,' ]+/, \"\", \$NF);
44+
files[NR]=\$1; v=\$NF; versions[NR]=v;
45+
v2n=version_to_number(v);
46+
if (v2n > max)
47+
max=v2n
48+
}
49+
3150
END {
3251
for (i in files) {
33-
if (versions[i] == max) {
52+
if (version_to_number(versions[i]) == max) {
3453
s=\" MAX 👈\"
3554
} else {
36-
s = \"\"};
37-
printf(\"%-45s: %s%s\\n\", files[i], versions[i], s)};
55+
s = \"\"
56+
}
57+
printf(\"%-65s: %s%s\\n\", files[i], versions[i], s)
58+
}
3859
}
3960
"
4061
;;

0 commit comments

Comments
 (0)