public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-functions:master commit in: /, functions/
Date: Sun,  7 Jul 2024 05:55:39 +0000 (UTC)	[thread overview]
Message-ID: <1719801147.23ce043cfccf6b39caf790464c18f2df1d5b7d1b.sam@gentoo> (raw)

commit:     23ce043cfccf6b39caf790464c18f2df1d5b7d1b
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jul  1 02:29:27 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> 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 <kfm <AT> 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


             reply	other threads:[~2024-07-07  5:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-07  5:55 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-08-11 10:11 [gentoo-commits] proj/gentoo-functions:master commit in: /, functions/ Sam James
2024-08-02 23:14 Sam James
2024-07-07  5:55 Sam James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1719801147.23ce043cfccf6b39caf790464c18f2df1d5b7d1b.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox