Author: waldi Date: Fri Feb 26 14:25:52 2010 New Revision: 712 Log: scripts/xen-version: Also work if VERBOSE is predefined. Modified: trunk/xen-common/scripts/xen-version Modified: trunk/xen-common/scripts/xen-version =============================================================================--- trunk/xen-common/scripts/xen-version Fri Feb 26 14:12:56 2010 (r711) +++ trunk/xen-common/scripts/xen-version Fri Feb 26 14:25:52 2010 (r712) @@ -1,5 +1,7 @@ #!/bin/bash +VERBOSE+ while getopts "v" OPT; do case "$OPT" in v) @@ -8,6 +10,12 @@ esac done +warn() { + if [ "$VERBOSE" ]; then + echo "WARNING! " "$@" >&2 + fi +} + if [ -e "/sys/hypervisor/type" ]; then if [ "$(cat /sys/hypervisor/type)" = xen ]; then DIR=/sys/hypervisor/version @@ -18,10 +26,10 @@ VERSION="$(cat $DIR/major).$(cat $DIR/minor)$VERSION_EXTRA" fi else - [ "$VERBOSE" ] && echo "WARING! Can''t read type from sysfs!" >&2 + warn "Can''t read type from sysfs!" fi else - [ "$VERBOSE" ] && echo "WARING! Can''t find hypervisor information in sysfs!" >&2 + warn "Can''t find hypervisor information in sysfs!" fi echo "$VERSION"