Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
PR #1802: add WARNING to base.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaudill authored Jan 12, 2024
1 parent 32b6e8d commit 78aae5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/ch-convert
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ chimage_out_validate () {
FATAL "exists in ch-image storage, not deleting per --no-clobber: ${1}"
fi
if [ -n "$xattrs" ]; then
WARNING "--xattrs unsupported for out format \"ch-image\""
WARNING -- "--xattrs unsupported for out format \"ch-image\""
fi
}

Expand Down
20 changes: 20 additions & 0 deletions lib/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ ch_lib=${ch_bin}/../lib
# Python code.
log_level=0

# Logging functions. Note that we disable SC2059 because we want these functions
# to behave exactly like printf(1), e.g. we want
#
# >>> VERBOSE "foo %s" "bar"
# foo bar
#
# Implementing the suggestion in SC2059 would instead result in something like
#
# >>> VERBOSE "foo %s" "bar"
# foo %sbar

DEBUG () {
if [ "$log_level" -ge 2 ]; then
# shellcheck disable=SC2059
Expand Down Expand Up @@ -45,6 +56,15 @@ VERBOSE () {
fi
}

WARNING () {
if [ "$log_level" -ge -1 ]; then
printf 'warning: ' 1>&2
# shellcheck disable=SC2059
printf "$@" 1>&2
printf '\n' 1>&2
fi
}

# Return success if path $1 exists, without dereferencing links, failure
# otherwise. (“test -e” dereferences.)
exist_p () {
Expand Down

0 comments on commit 78aae5e

Please sign in to comment.