summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2013-06-30 19:09:19 +0200
committerDominique Martinet <asmadeus@codewreck.org>2015-07-02 18:26:37 +0200
commitf793fe53fe1179031a4a119ad4fca0a28283ee6b (patch)
treeb064d40308d444957e229c6780def3b92bb1d1b7
parent3664b78143ee5e63c7648a801d17b24d6e7f3dff (diff)
don't parse arguments if script is sourced
-rwxr-xr-xkvm-wrapper.sh13
1 files changed, 8 insertions, 5 deletions
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index 677333f..0dcb48d 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -1089,11 +1089,6 @@ function print_help ()
exit 2
}
-if [[ $# -eq 0 ]]; then
- print_help;
- exit 0;
-fi
-
test_dir "$ROOTDIR" || fail_exit "Couldn't open kvm-wrapper's root directory:\n$ROOTDIR"
test_file "$CONFFILE" || fail_exit "Couldn't open kvm-wrapper's configuration file:\n$CONFFILE"
@@ -1105,6 +1100,14 @@ test_file "$CLUSTER_CONF" && source "$CLUSTER_CONF"
# Check VM descriptor directory
test_dir "$VM_DIR" || fail_exit "Couldn't open VM descriptor directory:\n$VM_DIR"
+# if we're being sourced, don't parse arguments
+[[ $(caller | cut -d' ' -f1) != "0" ]] && return 0
+
+if [[ $# -eq 0 ]]; then
+ print_help;
+ exit 0;
+fi
+
case "$1" in
list)
kvm_list "$2"