On Fri, Jun 5, 2026 at 8:05 AM Jonathan Wakely <[email protected]> wrote:
>
> 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.
> ---
>
> OK for trunk?

Ok. I went and checked that POSIX-2004 defined command the say way.
Just in case there was any portability issues with some older systems.

Thanks,
Drea

>
> 'command -v' is defined by POSIX:
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
>
>  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
> --
> 2.54.0
>

Reply via email to