]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
contrib: Use 'command -v' in download_prerequisites
authorJonathan Wakely <jwakely@redhat.com>
Fri, 5 Jun 2026 14:54:44 +0000 (15:54 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 5 Jun 2026 20:20:01 +0000 (21:20 +0100)
If wget is not installed, this script prints a message to standard error
which makes it looks like something is wrong:

./contrib/download_prerequisites: line 53: type: wget: not found

But if curl is installed then the script works fine. The command should
also redirect stderr with 2>&1 but it seems preferable to just replace
the use of 'type' with 'command -v' which is silent when the command is
not found.

Also add an explicit check for curl and print a more helpful error if
not found.

contrib/ChangeLog:

* download_prerequisites: use 'command -v' to check for wget and
curl.

contrib/download_prerequisites

index de3c8f0582dc64c52828489698d414504a150e7f..9e4bed94bedf18e0b521854d53adaeb0cfd39061 100755 (executable)
@@ -50,10 +50,17 @@ force=0
 only_gettext=false
 OS=$(uname)
 
-if type wget > /dev/null ; then
+die() {
+    echo "error: $@" >&2
+    exit 1
+}
+
+if command -v wget > /dev/null ; then
   fetch='wget'
-else
+elif command -v curl > /dev/null ; then
   fetch='curl -LO'
+else
+  die "Install wget or curl"
 fi
 chksum_extension='sha512'
 directory='.'
@@ -86,11 +93,6 @@ Copyright (C) 2016-2026 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 
-die() {
-    echo "error: $@" >&2
-    exit 1
-}
-
 for arg in "$@"
 do
     case "${arg}" in