diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2013-06-30 19:09:19 +0200 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2015-07-02 18:26:37 +0200 |
commit | f793fe53fe1179031a4a119ad4fca0a28283ee6b (patch) | |
tree | b064d40308d444957e229c6780def3b92bb1d1b7 | |
parent | 3664b78143ee5e63c7648a801d17b24d6e7f3dff (diff) |
don't parse arguments if script is sourced
-rwxr-xr-x | kvm-wrapper.sh | 13 |
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" |