From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- packaging/macos/jhb/usr/src/bash_d/echo.sh | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 packaging/macos/jhb/usr/src/bash_d/echo.sh (limited to 'packaging/macos/jhb/usr/src/bash_d/echo.sh') diff --git a/packaging/macos/jhb/usr/src/bash_d/echo.sh b/packaging/macos/jhb/usr/src/bash_d/echo.sh new file mode 100644 index 0000000..d160db0 --- /dev/null +++ b/packaging/macos/jhb/usr/src/bash_d/echo.sh @@ -0,0 +1,52 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# Provide colorful convenience functions for echo. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced + +### includes ################################################################### + +bash_d_include ansi + +### variables ################################################################## + +# Nothing here. + +### functions ################################################################## + +function echo_message__ +{ + local funcname=$1 # empty if outside function + local filename=$2 + local type=$3 + local color=$4 + local args=${*:5} + + if [ -z "$funcname" ] || [ "$funcname" = "source" ]; then + funcname=$(basename "$filename") + fi + + if ansi_is_usable; then + echo -e "${color}$type:$ANSI_FG_RESET $args ${ANSI_FG_BLACK_BRIGHT}[$funcname]$ANSI_FG_RESET" + else + echo "$type: $args [$funcname]" + fi +} + +### aliases #################################################################### + +alias echo_d='>&2 echo_message__ "$FUNCNAME" "${BASH_SOURCE[0]}" "debug" "$ANSI_FG_BLUE_BOLD"' +alias echo_e='>&2 echo_message__ "$FUNCNAME" "${BASH_SOURCE[0]}" "error" "$ANSI_FG_RED_BRIGHT"' +alias echo_i='>&2 echo_message__ "$FUNCNAME" "${BASH_SOURCE[0]}" "info" "$ANSI_FG_BLUE_BRIGHT"' +alias echo_o='>&2 echo_message__ "$FUNCNAME" "${BASH_SOURCE[0]}" "ok" "$ANSI_FG_GREEN_BRIGHT"' +alias echo_w='>&2 echo_message__ "$FUNCNAME" "${BASH_SOURCE[0]}" "warning" "$ANSI_FG_YELLOW_BRIGHT"' + +### main ####################################################################### + +# Nothing here. -- cgit v1.2.3