Skip to content

Commit c8982c2

Browse files
committed
Switch from echo -e to the safer printf '%b\n' in log functions
1 parent d998311 commit c8982c2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/log.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fi
2323
# ------------------------------------------------------------------------------
2424
bashio::log() {
2525
local message=$*
26-
echo -e "${message}" >&"$LOG_FD"
26+
printf '%b\n' "${message}" >&"$LOG_FD"
2727
return "${__BASHIO_EXIT_OK}"
2828
}
2929

@@ -35,7 +35,7 @@ bashio::log() {
3535
# ------------------------------------------------------------------------------
3636
bashio::log.red() {
3737
local message=$*
38-
echo -e "${__BASHIO_COLORS_RED}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
38+
printf '%b\n' "${__BASHIO_COLORS_RED}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
3939
return "${__BASHIO_EXIT_OK}"
4040
}
4141

@@ -47,7 +47,7 @@ bashio::log.red() {
4747
# ------------------------------------------------------------------------------
4848
bashio::log.green() {
4949
local message=$*
50-
echo -e "${__BASHIO_COLORS_GREEN}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
50+
printf '%b\n' "${__BASHIO_COLORS_GREEN}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
5151
return "${__BASHIO_EXIT_OK}"
5252
}
5353

@@ -59,7 +59,7 @@ bashio::log.green() {
5959
# ------------------------------------------------------------------------------
6060
bashio::log.yellow() {
6161
local message=$*
62-
echo -e "${__BASHIO_COLORS_YELLOW}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
62+
printf '%b\n' "${__BASHIO_COLORS_YELLOW}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
6363
return "${__BASHIO_EXIT_OK}"
6464
}
6565

@@ -71,7 +71,7 @@ bashio::log.yellow() {
7171
# ------------------------------------------------------------------------------
7272
bashio::log.blue() {
7373
local message=$*
74-
echo -e "${__BASHIO_COLORS_BLUE}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
74+
printf '%b\n' "${__BASHIO_COLORS_BLUE}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
7575
return "${__BASHIO_EXIT_OK}"
7676
}
7777

@@ -83,7 +83,7 @@ bashio::log.blue() {
8383
# ------------------------------------------------------------------------------
8484
bashio::log.magenta() {
8585
local message=$*
86-
echo -e "${__BASHIO_COLORS_MAGENTA}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
86+
printf '%b\n' "${__BASHIO_COLORS_MAGENTA}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
8787
return "${__BASHIO_EXIT_OK}"
8888
}
8989

@@ -95,7 +95,7 @@ bashio::log.magenta() {
9595
# ------------------------------------------------------------------------------
9696
bashio::log.cyan() {
9797
local message=$*
98-
echo -e "${__BASHIO_COLORS_CYAN}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
98+
printf '%b\n' "${__BASHIO_COLORS_CYAN}${message}${__BASHIO_COLORS_RESET}" >&"$LOG_FD"
9999
return "${__BASHIO_EXIT_OK}"
100100
}
101101

@@ -123,7 +123,7 @@ function bashio::log.log() {
123123
output="${output//\{MESSAGE\}/"${message}"}"
124124
output="${output//\{LEVEL\}/"${__BASHIO_LOG_LEVELS[$level]}"}"
125125

126-
echo -e "${output}" >&"$LOG_FD"
126+
printf '%b\n' "${output}" >&"$LOG_FD"
127127

128128
return "${__BASHIO_EXIT_OK}"
129129
}

0 commit comments

Comments
 (0)