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 E016F158011 for ; Tue, 14 Feb 2023 03:40:32 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EC658E0798; Tue, 14 Feb 2023 03:40:31 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.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) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D72FDE0798 for ; Tue, 14 Feb 2023 03:40:31 +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) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0BE84340B54 for ; Tue, 14 Feb 2023 03:40:31 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3E7768AC for ; Tue, 14 Feb 2023 03:40:29 +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: <1676345989.ee5ecbda72c1b6f39878ef16d52d48a4d7d0636d.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: ee5ecbda72c1b6f39878ef16d52d48a4d7d0636d X-VCS-Branch: master Date: Tue, 14 Feb 2023 03:40:29 +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: 197966e0-6212-40e8-a3ab-0722d3aa4eda X-Archives-Hash: 97d4cdb2a26dd30dbaa7b51b6d844e9b commit: ee5ecbda72c1b6f39878ef16d52d48a4d7d0636d Author: Kerin Millar plushkava net> AuthorDate: Tue Feb 14 00:38:12 2023 +0000 Commit: Sam James gentoo org> CommitDate: Tue Feb 14 03:39:49 2023 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=ee5ecbda Have _eend() show the name of the calling function in its diagnostics Currently, the diagnostic message reports that an invalid argument was given to "_eend". Given that it is intended as a private function, users of this library would be better off seeing the name of the function that they originally invoked. Make it possible by having eend(), ewend(), veend() and vewend() set the CALLER variable in the execution environment of _eend(), duly affecting the content of the message. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> functions.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions.sh b/functions.sh index 28764d8..82d2192 100644 --- a/functions.sh +++ b/functions.sh @@ -249,7 +249,7 @@ _eend() if [ "$#" -eq 0 ]; then retval=0 elif ! is_int "$1" || [ "$1" -lt 0 ]; then - printf 'Invalid argument given to _eend (the exit status code must be an integer >= 0)\n' >&2 + printf 'Invalid argument given to %s (the exit status code must be an integer >= 0)\n' "${CALLER}" >&2 retval=0 shift else @@ -286,7 +286,7 @@ eend() { local retval - _eend eerror "$@" + CALLER=${CALLER:-eend} _eend eerror "$@" retval=$? LAST_E_CMD="eend" return "${retval}" @@ -300,7 +300,7 @@ ewend() { local retval - _eend ewarn "$@" + CALLER=${CALLER:-ewend} _eend ewarn "$@" retval=$? LAST_E_CMD="ewend" return "${retval}" @@ -345,7 +345,7 @@ vebegin() veend() { if yesno "${EINFO_VERBOSE}"; then - eend "$@" + CALLER=veend eend "$@" elif [ "$#" -gt 0 ] && { ! is_int "$1" || [ "$1" -lt 0 ]; }; then printf 'Invalid argument given to veend (the exit status code must be an integer >= 0)\n' >&2 else @@ -356,7 +356,7 @@ veend() vewend() { if yesno "${EINFO_VERBOSE}"; then - ewend "$@" + CALLER=vewend ewend "$@" elif [ "$#" -gt 0 ] && { ! is_int "$1" || [ "$1" -lt 0 ]; }; then printf 'Invalid argument given to vewend (the exit status code must be an integer >= 0)\n' >&2 else