Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

livepatch/klp-build: add terminal color output

Improve the readability of klp-build output by implementing a basic
color scheme. When the standard output and error are connected to a
terminal, highlight status messages in bold and warning/error prefixes
in yellow/red.

Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Link: https://patch.msgid.link/20260310203751.1479229-12-joe.lawrence@redhat.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

authored by

Joe Lawrence and committed by
Josh Poimboeuf
1fbc9b85 b41d8b7d

+13 -4
+13 -4
scripts/livepatch/klp-build
··· 52 52 53 53 KLP_DIFF_LOG="$DIFF_DIR/diff.log" 54 54 55 + # Terminal output colors 56 + read -r COLOR_RESET COLOR_BOLD COLOR_ERROR COLOR_WARN <<< "" 57 + if [[ -t 1 && -t 2 ]]; then 58 + COLOR_RESET="\033[0m" 59 + COLOR_BOLD="\033[1m" 60 + COLOR_ERROR="\033[0;31m" 61 + COLOR_WARN="\033[0;33m" 62 + fi 63 + 55 64 grep0() { 56 65 # shellcheck disable=SC2317 57 66 command grep "$@" || true ··· 74 65 } 75 66 76 67 status() { 77 - echo "$*" 68 + echo -e "${COLOR_BOLD}$*${COLOR_RESET}" 78 69 } 79 70 80 71 warn() { 81 - echo "error: $SCRIPT: $*" >&2 72 + echo -e "${COLOR_WARN}warning${COLOR_RESET}: $SCRIPT: $*" >&2 82 73 } 83 74 84 75 die() { 85 - warn "$@" 76 + echo -e "${COLOR_ERROR}error${COLOR_RESET}: $SCRIPT: $*" >&2 86 77 exit 1 87 78 } 88 79 ··· 119 110 } 120 111 121 112 trap_err() { 122 - warn "line ${BASH_LINENO[0]}: '$BASH_COMMAND'" 113 + die "line ${BASH_LINENO[0]}: '$BASH_COMMAND'" 123 114 } 124 115 125 116 trap cleanup EXIT INT TERM HUP