configure: silence 'shift' error message in version_ge()
authorStefano Garzarella <sgarzare@redhat.com>
Fri, 21 Aug 2020 20:35:58 +0000 (22:35 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 21 Aug 2020 21:03:11 +0000 (17:03 -0400)
If there are less than 2 arguments in version_ge(), the second
'shift' prints this error:
    ../configure: line 232: shift: shift count out of range

As Eric suggested, we can use 'shift ${2:+2}' which works out to
'shift 2' if $2 is set, or 'shift' (implicitly shift 1) if $2
is not set.

This patch replaces both 'shift; shift' occurrences in version_ge()
with 'shift ${2:+2}'.

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200821203558.10338-1-sgarzare@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
configure

index 4e5fe3321108d20c2e9c4dc20239a436ddc6ff71..d9ca87fbbb521953d1d56f49f742d5a6e511a4a7 100755 (executable)
--- a/configure
+++ b/configure
@@ -228,15 +228,15 @@ version_ge () {
     while true; do
         set x $local_ver1
         local_first=${2-0}
-        # shift 2 does nothing if there are less than 2 arguments
-        shift; shift
+        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
+        shift ${2:+2}
         local_ver1=$*
         set x $local_ver2
         # the second argument finished, the first must be greater or equal
         test $# = 1 && return 0
         test $local_first -lt $2 && return 1
         test $local_first -gt $2 && return 0
-        shift; shift
+        shift ${2:+2}
         local_ver2=$*
     done
 }