From 5116e84e22608d055a3e7bbffdca2e857264c84f Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 04 Sep 2012 22:00:36 -0400 Subject: Move and partially rewrite output library module. --- (limited to 'lib/output.sh') diff --git a/lib/output.sh b/lib/output.sh new file mode 100644 index 0000000..f5bfd34 --- /dev/null +++ b/lib/output.sh @@ -0,0 +1,61 @@ +# opkbuild +# lib/output +# Functions for printing messages. +# +# Copyright (C) 2012 Patrick "P. J." McDermott +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +[ -n "${_OB_MESSAGES_SH}" ] && return 0 +_OB_MESSAGES_SH=true + +. @@LIBOPKBUILD@@/locale.sm + +# TODO: Which of these should print to the standard error stream – just +# ob_error() and ob_warn()? + +ob_error() +{ + printf '%s: Error: ' "${0##*/}" + printf "${@}" + printf '\n' + + exit 1 +} + +ob_warn() +{ + if [ ${#} -eq 0 ]; then + return 125 + fi + + printf '%s: Warning: ' "${0##*/}" + printf "${@}" + printf '\n' + + return 0 +} + +ob_info() +{ + if [ ${#} -eq 0 ]; then + return 125 + fi + + printf '%s: ' "${0##*/}" + printf "${@}" + printf '\n' + + return 0 +} -- cgit v0.9.1