From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id BB4D01581C1 for ; Sun, 7 Jul 2024 05:55:44 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EC502E2A71; Sun, 7 Jul 2024 05:55:42 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C6AF9E2A6A for ; Sun, 7 Jul 2024 05:55:42 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7D481340CB1 for ; Sun, 7 Jul 2024 05:55:41 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0DF481DE0 for ; Sun, 7 Jul 2024 05:55:39 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1719801147.23ce043cfccf6b39caf790464c18f2df1d5b7d1b.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: /, functions/ X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh functions/experimental.sh X-VCS-Directories: / functions/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 23ce043cfccf6b39caf790464c18f2df1d5b7d1b X-VCS-Branch: master Date: Sun, 7 Jul 2024 05:55:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: a7ff9cc4-7cc2-441e-a045-eb789c643797 X-Archives-Hash: b24017222a53c2464be0ec989aca9d97 commit: 23ce043cfccf6b39caf790464c18f2df1d5b7d1b Author: Kerin Millar plushkava net> AuthorDate: Mon Jul 1 02:29:27 2024 +0000 Commit: Sam James gentoo org> CommitDate: Mon Jul 1 02:32:27 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=23ce043c Move fetch() to experimental I'm not yet ready to commit to it being among the core functions for the inaugural API level. Signed-off-by: Kerin Millar plushkava.net> functions.sh | 42 ------------------------------------------ functions/experimental.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/functions.sh b/functions.sh index a4fa946..cfaddc3 100644 --- a/functions.sh +++ b/functions.sh @@ -138,48 +138,6 @@ contains_any() return "${retval}" } -# -# Considers the first parameter as an URL then attempts to fetch it with either -# curl(1) or wget(1). If the URL does not contain a scheme then the https:// -# scheme shall be presumed. Both utilities shall be invoked in a manner that -# suppresses all output unless an error occurs, and whereby HTTP redirections -# are honoured. Upon success, the body of the response shall be printed to the -# standard output. Otherwise, the return value shall be greater than 0. -# -fetch() -{ - if hash curl 2>/dev/null; then - fetch() - { - if [ "$#" -gt 0 ]; then - # Discard any extraneous parameters. - set -- "$1" - fi - curl -f -sS -L --connect-timeout 10 --proto-default https -- "$@" - } - elif hash wget 2>/dev/null; then - fetch() - { - if [ "$#" -gt 0 ]; then - # Discard any extraneous parameters. - case $1 in - ''|ftp://*|ftps://*|https://*) - set -- "$1" - ;; - *) - set -- "https://$1" - esac - fi - wget -nv -O - --connect-timeout 10 -- "$@" - } - else - warn "fetch: this function requires that curl or wget be installed" - return 127 - fi - - fetch "$@" -} - # # Determines whether the current shell is a subprocess of portage. # diff --git a/functions/experimental.sh b/functions/experimental.sh index 4d56cfa..bbbf0fa 100644 --- a/functions/experimental.sh +++ b/functions/experimental.sh @@ -12,6 +12,48 @@ warn "sourcing the experimental module from gentoo-functions; no stability guarantee is provided" +# +# Considers the first parameter as an URL then attempts to fetch it with either +# curl(1) or wget(1). If the URL does not contain a scheme then the https:// +# scheme shall be presumed. Both utilities shall be invoked in a manner that +# suppresses all output unless an error occurs, and whereby HTTP redirections +# are honoured. Upon success, the body of the response shall be printed to the +# standard output. Otherwise, the return value shall be greater than 0. +# +fetch() +{ + if hash curl 2>/dev/null; then + fetch() + { + if [ "$#" -gt 0 ]; then + # Discard any extraneous parameters. + set -- "$1" + fi + curl -f -sS -L --connect-timeout 10 --proto-default https -- "$@" + } + elif hash wget 2>/dev/null; then + fetch() + { + if [ "$#" -gt 0 ]; then + # Discard any extraneous parameters. + case $1 in + ''|ftp://*|ftps://*|https://*) + set -- "$1" + ;; + *) + set -- "https://$1" + esac + fi + wget -nv -O - --connect-timeout 10 -- "$@" + } + else + warn "fetch: this function requires that curl or wget be installed" + return 127 + fi + + fetch "$@" +} + # # Expects three parameters, all of which must be integers, and determines # whether the first is numerically greater than or equal to the second, and