aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2017-06-20 08:18:08 -0700
committerPaul Eggert2017-06-20 08:18:55 -0700
commit6fcbbc393eced8350f6d4679d8070bfc48244aab (patch)
treed33fc2f9ad373050b25de6429a833bd64d4959e7
parentefa2b08dcbf0177ef5bc21216ddd3876a9fc79e3 (diff)
downloademacs-6fcbbc393eced8350f6d4679d8070bfc48244aab.tar.gz
emacs-6fcbbc393eced8350f6d4679d8070bfc48244aab.zip
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.
-rwxr-xr-xautogen.sh17
1 files changed, 4 insertions, 13 deletions
diff --git a/autogen.sh b/autogen.sh
index 9fdd492456f..76fde9e18d2 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -45,10 +45,8 @@ autoconf_min=`sed -n 's/^ *AC_PREREQ(\([0-9\.]*\)).*/\1/p' configure.ac`
45## Also note that we do not handle micro versions. 45## Also note that we do not handle micro versions.
46get_version () 46get_version ()
47{ 47{
48 vers=`$1 --version 2> /dev/null` 48 vers=`($1 --version) 2> /dev/null` && expr "$vers" : '[^
49 [ x"$vers" = x ] && return 1 49]* \([0-9][0-9.]*\).*'
50
51 echo "$vers" | sed -n -e '1 s/.* \([0-9][0-9\.]*\).*/\1/p'
52} 50}
53 51
54## $1 = version string, eg "2.59" 52## $1 = version string, eg "2.59"
@@ -84,15 +82,8 @@ check_version ()
84 printf '%s' "(using $uprog0=$uprog) " 82 printf '%s' "(using $uprog0=$uprog) "
85 fi 83 fi
86 84
87 found=`command -v $uprog 2> /dev/null` 85 command -v $uprog > /dev/null || return 1
88 [ x"$found" = x ] && return 1 86 have_version=`get_version $uprog` || return 4
89
90 have_version=`get_version $uprog`
91
92 ## We should really check the return status of get_version.
93 ## Non-zero means a broken executable, otherwise we failed to
94 ## parse the version string.
95 [ x"$have_version" = x ] && return 4
96 87
97 have_maj=`major_version $have_version` 88 have_maj=`major_version $have_version`
98 need_maj=`major_version $2` 89 need_maj=`major_version $2`