summaryrefslogtreecommitdiffstats
path: root/lib/output.sh
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-09-04 22:00:36 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-09-04 22:00:36 (EDT)
commit5116e84e22608d055a3e7bbffdca2e857264c84f (patch)
treedff99b8cd5821dacc1fbdde42a351405093d41f5 /lib/output.sh
parent97c59d2c93b7fd64dc46da8ce42427e9a74de98c (diff)
Move and partially rewrite output library module.
Diffstat (limited to 'lib/output.sh')
-rw-r--r--lib/output.sh61
1 files changed, 61 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>.
+
+[ -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
+}