[gcc r17-1383] contrib: Use 'command -v' in download_prerequisites
Jonathan Wakely
redi@gcc.gnu.org
Fri Jun 5 20:20:17 GMT 2026
https://gcc.gnu.org/g:2ffe26f6fc17c279c017ffc215f03288ded7884e
commit r17-1383-g2ffe26f6fc17c279c017ffc215f03288ded7884e
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Jun 5 15:54:44 2026 +0100
contrib: Use 'command -v' in download_prerequisites
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.
Diff:
---
contrib/download_prerequisites | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/contrib/download_prerequisites b/contrib/download_prerequisites
index de3c8f0582dc..9e4bed94bedf 100755
--- a/contrib/download_prerequisites
+++ b/contrib/download_prerequisites
@@ -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
More information about the Gcc-cvs
mailing list