emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 6fcbbc3: Simplify autogen.sh version checking


From: Paul Eggert
Subject: [Emacs-diffs] master 6fcbbc3: Simplify autogen.sh version checking
Date: Tue, 20 Jun 2017 11:19:01 -0400 (EDT)

branch: master
commit 6fcbbc393eced8350f6d4679d8070bfc48244aab
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Simplify autogen.sh version checking
    
    * autogen.sh (get_version): Simplify and make more reliable
    by using expr rather than echo | sed.  Check exit status of program.
    Run program in subshell in case it cannot be executed.
    (check_version): Check exit status of command rather than its output.
    Check return status of get_version.
---
 autogen.sh | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index 9fdd492..76fde9e 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -45,10 +45,8 @@ autoconf_min=`sed -n 's/^ *AC_PREREQ(\([0-9\.]*\)).*/\1/p' 
configure.ac`
 ## Also note that we do not handle micro versions.
 get_version ()
 {
-    vers=`$1 --version 2> /dev/null`
-    [ x"$vers" = x ] && return 1
-
-    echo "$vers" | sed -n -e '1 s/.* \([0-9][0-9\.]*\).*/\1/p'
+    vers=`($1 --version) 2> /dev/null` && expr "$vers" : '[^
+]* \([0-9][0-9.]*\).*'
 }
 
 ## $1 = version string, eg "2.59"
@@ -84,15 +82,8 @@ check_version ()
         printf '%s' "(using $uprog0=$uprog) "
     fi
 
-    found=`command -v $uprog 2> /dev/null`
-    [ x"$found" = x ] && return 1
-
-    have_version=`get_version $uprog`
-
-    ## We should really check the return status of get_version.
-    ## Non-zero means a broken executable, otherwise we failed to
-    ## parse the version string.
-    [ x"$have_version" = x ] && return 4
+    command -v $uprog > /dev/null || return 1
+    have_version=`get_version $uprog` || return 4
 
     have_maj=`major_version $have_version`
     need_maj=`major_version $2`



reply via email to

[Prev in Thread] Current Thread [Next in Thread]