diff mbox series

[v1,07/15] configure: make version_ge more tolerant of shady version input

Message ID 20210202134001.25738-8-alex.bennee@linaro.org
State New
Headers show
Series testing/gdbstub/docs pre-PR | expand

Commit Message

Alex Bennée Feb. 2, 2021, 1:39 p.m. UTC
When checking GDB versions we have to tolerate all sorts of random
distro extensions to the version string. While we already attempt to
do some of that before we call version_ge is makes sense to try and
regularise the first input by stripping extraneous -'s. While we at it
convert the old-style shell quoting into a cleaner form t shut up my
editors linter lest it confuse me by underlining the whole line.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Eric Blake Feb. 2, 2021, 2:17 p.m. UTC | #1
On 2/2/21 7:39 AM, Alex Bennée wrote:
> When checking GDB versions we have to tolerate all sorts of random
> distro extensions to the version string. While we already attempt to
> do some of that before we call version_ge is makes sense to try and
> regularise the first input by stripping extraneous -'s. While we at it
> convert the old-style shell quoting into a cleaner form t shut up my
> editors linter lest it confuse me by underlining the whole line.
> 
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Tested-by: Thomas Huth <thuth@redhat.com>
> ---
>  configure | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index e85d6baf8f..432b83fadf 100755
> --- a/configure
> +++ b/configure
> @@ -198,8 +198,8 @@ has() {
>  }
>  
>  version_ge () {
> -    local_ver1=`echo $1 | tr . ' '`
> -    local_ver2=`echo $2 | tr . ' '`
> +    local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
> +    local_ver2=$(echo "$2" | tr . ' ')
>      while true; do
>          set x $local_ver1
>          local_first=${2-0}
> 

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/configure b/configure
index e85d6baf8f..432b83fadf 100755
--- a/configure
+++ b/configure
@@ -198,8 +198,8 @@  has() {
 }
 
 version_ge () {
-    local_ver1=`echo $1 | tr . ' '`
-    local_ver2=`echo $2 | tr . ' '`
+    local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
+    local_ver2=$(echo "$2" | tr . ' ')
     while true; do
         set x $local_ver1
         local_first=${2-0}