configure: silence 'shift' error message in version_ge()
PATCH v3 1/1 configure: silence 'shift' error message in version_ge()
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}'.
---
v3:
- use Eric's one-liner solution
v2:
- do not shift if there are no more arguments [Peter]
--- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
configure +3 -3
@@ -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 }
Signature · 1 line
2.26.2
Quoted 13 lines · Stefano Garzarella
If there are less than 2 arguments in
version_ge(), the second 'shift' prints this error:
../configure: line 232: shift: shift count out of rangeAs 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 <[email protected]>Signed-off-by Stefano Garzarella <[email protected]>
Quoted 8 lines
---
v3:
- use Eric's one-liner solution
v2:
- do not shift if there are no more arguments [Peter]--- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org