From f3a408c4b1b86a7cc7a2d1c6962ae76ccd6ea9da Mon Sep 17 00:00:00 2001 From: arcctgx Date: Wed, 25 Apr 2018 20:16:03 +0200 Subject: [PATCH] Fix bug in updates_compare_versions() The loop index $i was not protected with curly braces in eval statement of variable LEFT. When i=10 that statement was not evaluated as $10, but as $1 concatenated with the digit 0. Corrected description of outputs of updates_compare_versions(). --- src/usr/sbin/sbopkg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usr/sbin/sbopkg b/src/usr/sbin/sbopkg index dc69d86..fab4922 100755 --- a/src/usr/sbin/sbopkg +++ b/src/usr/sbin/sbopkg @@ -971,14 +971,14 @@ updates_compare_versions() { # 1.2.50 build 4, the argument list is # 1 2 3 7 1 2 50 4 # Prints -1 if the "left" package is newer (not an update), 0 if - # the version is unchanged, 1 if the "left" package is newer. + # the version is unchanged, 1 if the "left" package is older. local COUNT=$(($# / 2)) local i RESULT=0 local LEFT RIGHT for ((i=1; i<=$COUNT; i++)); do - eval LEFT=\$$i + eval LEFT=\${$i} eval RIGHT=\${$(($i + $COUNT))} if [[ 10#$LEFT -lt 10#$RIGHT ]]; then RESULT=1