This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=7a897c1df718c93ff8cfaccfca17b24f1ca083f5 commit 7a897c1df718c93ff8cfaccfca17b24f1ca083f5 Author: Guillem Jover <[email protected]> AuthorDate: Fri Dec 6 01:55:05 2024 +0100 src/sh: Move setup_colors() contents into dpkg-error.sh script scope The function was not written to handle being called multiple times to perform different setups based on different inputs. Any script sourcing this file was required to call this function as it setups variables used by the various functions, which is unnecessary boilerplate that we can get rid of. Preserve an empty setup_colors() function for backwards compatibility with code calling it. --- src/sh/dpkg-error.sh | 56 ++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/sh/dpkg-error.sh b/src/sh/dpkg-error.sh index a67cb3d69..0e0d1a6da 100644 --- a/src/sh/dpkg-error.sh +++ b/src/sh/dpkg-error.sh @@ -41,36 +41,40 @@ COLOR_BOLD_MAGENTA='[1;35m' COLOR_BOLD_CYAN='[1;36m' COLOR_BOLD_WHITE='[1;37m' -setup_colors() -{ - : "${DPKG_COLORS=auto}" +: "${DPKG_COLORS=auto}" - case "$DPKG_COLORS" in - auto) - if [ -t 1 ]; then - USE_COLORS=yes - else - USE_COLORS=no - fi - ;; - always) +case "$DPKG_COLORS" in +auto) + if [ -t 1 ]; then USE_COLORS=yes - ;; - *) - USE_COLORS=no - ;; - esac - - if [ $USE_COLORS = yes ]; then - COLOR_PROG="$COLOR_BOLD" - COLOR_INFO="$COLOR_GREEN" - COLOR_NOTICE="$COLOR_YELLOW" - COLOR_WARN="$COLOR_BOLD_YELLOW" - COLOR_ERROR="$COLOR_BOLD_RED" else - COLOR_RESET="" + USE_COLORS=no fi - FMT_PROG="$COLOR_PROG$PROGNAME$COLOR_RESET" + ;; +always) + USE_COLORS=yes + ;; +*) + USE_COLORS=no + ;; +esac + +if [ $USE_COLORS = yes ]; then + COLOR_PROG="$COLOR_BOLD" + COLOR_INFO="$COLOR_GREEN" + COLOR_NOTICE="$COLOR_YELLOW" + COLOR_WARN="$COLOR_BOLD_YELLOW" + COLOR_ERROR="$COLOR_BOLD_RED" +else + COLOR_RESET="" +fi +FMT_PROG="$COLOR_PROG$PROGNAME$COLOR_RESET" + +# This function is deprecated and kept only for backwards compatibility. +# Deprecated since dpkg 1.22.12. +setup_colors() +{ + : } debug() { -- Dpkg.Org's dpkg

