Skip to content

Commit

Permalink
Ensure status log messages are printed with normal color (#884)
Browse files Browse the repository at this point in the history
* stdlib: Use "normal" color in log_status()

Reset color for normal status messages.

* stdlib: Set variables in log_error() only if needed
  • Loading branch information
tmatilai committed May 17, 2022
1 parent 11cf0a6 commit c767996
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions stdlib.sh
Expand Up @@ -135,8 +135,9 @@ direnv_layout_dir() {
log_status() {
if [[ -n $DIRENV_LOG_FORMAT ]]; then
local msg=$*
local color_normal="\e[m"
# shellcheck disable=SC2059,SC1117
printf "${DIRENV_LOG_FORMAT}\n" "$msg" >&2
printf "${color_normal}${DIRENV_LOG_FORMAT}\n" "$msg" >&2
fi
}

Expand All @@ -152,10 +153,10 @@ log_status() {
# log_error "Unable to find specified directory!"

log_error() {
local color_normal="\e[m"
local color_error="\e[38;5;1m"
if [[ -n $DIRENV_LOG_FORMAT ]]; then
local msg=$*
local color_normal="\e[m"
local color_error="\e[38;5;1m"
# shellcheck disable=SC2059,SC1117
printf "${color_error}${DIRENV_LOG_FORMAT}${color_normal}\n" "$msg" >&2
fi
Expand Down

0 comments on commit c767996

Please sign in to comment.