Skip to content

Commit

Permalink
Use local scope for variables in output helpers (#1719)
Browse files Browse the repository at this point in the history
Since `read` defines the `line variable as global by default,
meaning `line` was visible outside these functions.
  • Loading branch information
edmorley authored Dec 12, 2024
1 parent c4e4a4f commit e74c46e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function output::indent() {
# EOF
# ```
function output::notice() {
local line
echo >&2
while IFS= read -r line; do
echo -e "${ANSI_BLUE} ! ${line}${ANSI_RESET}" >&2
Expand All @@ -58,6 +59,7 @@ function output::notice() {
# EOF
# ```
function output::warning() {
local line
echo >&2
while IFS= read -r line; do
echo -e "${ANSI_YELLOW} ! ${line}${ANSI_RESET}" >&2
Expand All @@ -76,6 +78,7 @@ function output::warning() {
# EOF
# ```
function output::error() {
local line
echo >&2
while IFS= read -r line; do
echo -e "${ANSI_RED} ! ${line}${ANSI_RESET}" >&2
Expand Down

0 comments on commit e74c46e

Please sign in to comment.