configure: fix syntax error with NetBSD
authorDmitry Fomichev <dmitry.fomichev@wdc.com>
Mon, 17 Aug 2020 23:47:08 +0000 (08:47 +0900)
committerJens Axboe <axboe@kernel.dk>
Wed, 19 Aug 2020 13:05:17 +0000 (07:05 -0600)
The recent patch to detect for pkg-config presence has introduced some
bash-specific code to configure script. This lead to syntax errors
while running configure under some other shells, such as (d)ash.

Avoid ${!var} indirect substitution syntax and stop using "local"
keyword which is non-POSIX-standard. Address a few minor shellcheck
complaints about the code in same function.

Fixes: 162f8c2a96ae ("configure: check if pkg-config is installed")
Reviewed-by: Sitsofe Wheeler <sitsofe@yahoo.com>
Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
configure

index dd7fe3d298312aefa7ff809f2ae400e20116b9a1..d3997b5fff7787306ca270119b9d26149ab31c6b 100755 (executable)
--- a/configure
+++ b/configure
@@ -134,18 +134,18 @@ output_sym() {
 }
 
 check_min_lib_version() {
 }
 
 check_min_lib_version() {
-  local feature=$3
+  _feature=$3
 
 
-  if ${cross_prefix}pkg-config --atleast-version=$2 $1 > /dev/null 2>&1; then
+  if "${cross_prefix}"pkg-config --atleast-version="$2" "$1" > /dev/null 2>&1; then
     return 0
   fi
     return 0
   fi
-  : ${feature:=${1}}
-  if ${cross_prefix}pkg-config --version > /dev/null 2>&1; then
-    if test ${!feature} = "yes" ; then
-      feature_not_found "$feature" "$1 >= $2"
+  : "${_feature:=${1}}"
+  if "${cross_prefix}"pkg-config --version > /dev/null 2>&1; then
+    if eval "echo \$$_feature" = "yes" ; then
+      feature_not_found "$_feature" "$1 >= $2"
     fi
   else
     fi
   else
-    print_config "$1" "missing pkg-config, can't check $feature version"
+    print_config "$1" "missing pkg-config, can't check $_feature version"
   fi
   return 1
 }
   fi
   return 1
 }