[arch-projects] [RFC 02/23] Add some utilities
Matthew Monaco
dgbaley27 at 0x01b.net
Fri May 18 12:21:56 EDT 2012
From: Matthew Monaco <matthew.monaco at 0x01b.net>
How can I get the diff better here?
---
cryptmount.sh | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/cryptmount.sh b/cryptmount.sh
index dacfc1a..bd3ed86 100755
--- a/cryptmount.sh
+++ b/cryptmount.sh
@@ -50,6 +50,46 @@ __EOF__
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
# #
+# Utilities #
+# #
+
+error() {
+ [ $LOGLEVEL -ge 0 ] && printf "E: %s\n" "$*" >&2 || true
+}
+
+die() {
+ printf "E: %s\n" "$*" >&2
+ exit ${1:-1}
+}
+
+warn() {
+ [ $LOGLEVEL -ge 1 ] && printf "W: %s\n" "$*" >&2 || true
+}
+
+msg() {
+ [ $LOGLEVEL -ge 1 ] && printf "M: %s\n" "$*" >&2 || true
+}
+
+info() {
+ [ $LOGLEVEL -ge 2 ] && printf "I: %s\n" "$*" >&2 || true
+}
+
+run() {
+ [ $LOGLEVEL -ge 2 ] && printf "R: %s\n" "$*" >&2
+ if [ $DRYRUN -eq 1 ]; then
+ true
+ else
+ "$@"
+ fi
+}
+
+trim() {
+ local IFS=$' \t\n'
+ echo -n $*
+}
+
+# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
+# #
# Main functions #
# #
--
1.7.10.2
More information about the arch-projects
mailing list