Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit 78aae5e

Browse files
authored
PR #1802: add WARNING to base.sh
1 parent 32b6e8d commit 78aae5e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

bin/ch-convert

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ chimage_out_validate () {
474474
FATAL "exists in ch-image storage, not deleting per --no-clobber: ${1}"
475475
fi
476476
if [ -n "$xattrs" ]; then
477-
WARNING "--xattrs unsupported for out format \"ch-image\""
477+
WARNING -- "--xattrs unsupported for out format \"ch-image\""
478478
fi
479479
}
480480

lib/base.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ ch_lib=${ch_bin}/../lib
1313
# Python code.
1414
log_level=0
1515

16+
# Logging functions. Note that we disable SC2059 because we want these functions
17+
# to behave exactly like printf(1), e.g. we want
18+
#
19+
# >>> VERBOSE "foo %s" "bar"
20+
# foo bar
21+
#
22+
# Implementing the suggestion in SC2059 would instead result in something like
23+
#
24+
# >>> VERBOSE "foo %s" "bar"
25+
# foo %sbar
26+
1627
DEBUG () {
1728
if [ "$log_level" -ge 2 ]; then
1829
# shellcheck disable=SC2059
@@ -45,6 +56,15 @@ VERBOSE () {
4556
fi
4657
}
4758

59+
WARNING () {
60+
if [ "$log_level" -ge -1 ]; then
61+
printf 'warning: ' 1>&2
62+
# shellcheck disable=SC2059
63+
printf "$@" 1>&2
64+
printf '\n' 1>&2
65+
fi
66+
}
67+
4868
# Return success if path $1 exists, without dereferencing links, failure
4969
# otherwise. (“test -e” dereferences.)
5070
exist_p () {

0 commit comments

Comments
 (0)