bootstrap: improve error message
authorAkim Demaille <demaille@gostai.com>
Thu, 3 Sep 2009 07:55:06 +0000 (09:55 +0200)
committerJim Meyering <meyering@redhat.com>
Sun, 6 Sep 2009 08:20:16 +0000 (10:20 +0200)
* build-aux/bootstrap (find_tool): Upon failure, report the list
of candidates.
Honor the initial value of the envvar.

ChangeLog
build-aux/bootstrap

index b3fbaca..6aa927b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-06  Akim Demaille  <demaille@gostai.com>
+
+       bootstrap: improve error message
+       * build-aux/bootstrap (find_tool): Upon failure, report the list
+       of candidates.
+       Honor the initial value of the envvar.
+
 2009-09-05  Eric Blake  <ebb9@byu.net>
 
        symlinkat: new module
index 499e97f..b6dce12 100755 (executable)
@@ -150,12 +150,18 @@ vc_ignore=auto
 
 # find_tool ENVVAR NAMES...
 # -------------------------
+# Search for a required program.  Use the value of ENVVAR, if set,
+# otherwise find the first of the NAMES that can be run (i.e.,
+# supports --version).  If found, set ENVVAR to the program name,
+# die otherwise.
 find_tool ()
 {
   # Find sha1sum, named gsha1sum on MacPorts.
   find_tool_envvar=$1
   shift
-  if eval test x"\$$find_tool_envvar" = x; then
+  find_tool_names=$@
+  eval "find_tool_res=\$$find_tool_envvar"
+  if test x"$find_tool_res" = x; then
     for i
     do
       if ($i --version </dev/null) >/dev/null 2>&1; then
@@ -163,16 +169,18 @@ find_tool ()
        break
       fi
     done
+  else
+    find_tool_error_prefix="\$$find_tool_envvar: "
   fi
   if test x"$find_tool_res" = x; then
-    echo >&2 "$0: $find_tool_name is required"
+    echo >&2 "$0: one of these is required: $find_tool_names"
     exit 1
   fi
   ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
-    echo >&2 "$0: cannot run $find_tool_res --version"
+    echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version"
     exit 1
   }
-  eval "$find_tool_envvar=\"$find_tool_res\""
+  eval "$find_tool_envvar=\$find_tool_res"
   eval "export $find_tool_envvar"
 }