[PATCH 04/10] hal: Clean up scripts in tools
Victor Lowther
victor.lowther at gmail.com
Tue Mar 25 18:48:45 PDT 2008
Add a little environment-variable checking function to hal-functions
It seems like every script duplicated this code in one way or another.
Centralizing it for ease of maintenance.
---
tools/hal-functions | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/tools/hal-functions b/tools/hal-functions
index ec8db99..f37004a 100755
--- a/tools/hal-functions
+++ b/tools/hal-functions
@@ -23,6 +23,21 @@ hal_check_priv() {
fi
}
+# Check for environment variables. Seems like every hal script does this.
+hal_check_env() {
+ # $1 = value of env var.
+ # $2 (optional) = name of env var.
+ [ -n "$1" ] && return
+ echo "org.freedesktop.Hal.Device.UnknownError" >&2
+ if [ -z "$2" ]; then
+ echo "Missing or empty environment variable(s)." >&2
+ else
+ echo "Missing or empty environment variable $2" >&2
+ fi
+ echo "This script should be started by hald." >&2
+ exit 1
+fi
+
hal_call_backend() {
local PROGRAM
PROGRAM="./$HALD_UNAME_S/$(basename $0)-$HALD_UNAME_S"
--
1.5.4.3
More information about the hal
mailing list