diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2013-11-22 16:18:55 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2015-06-07 04:27:47 +0200 |
commit | 5df4738c72485e6788e70ce021ce266aa556acfa (patch) | |
tree | 2d8c0e3b1b765d0b3cd2d16680e76853db39f1ce /virtualenv | |
parent | 7870977adc6e8aec370b182561c3dd767a97322e (diff) |
wibble
Replaced [ -n "$string" ] with [ "$string" ], and [ -z "$string" ] with
[ ! "$string" ].
Diffstat (limited to 'virtualenv')
-rwxr-xr-x | virtualenv/virt | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/virtualenv/virt b/virtualenv/virt index b88d04e..043589f 100755 --- a/virtualenv/virt +++ b/virtualenv/virt @@ -10,7 +10,7 @@ set -ue root=$(dirname "$0") -help() { +usage() { cat >&2 <<-EOF Usage: $0 install <libvirt domain> [<QEMU image>] @@ -41,7 +41,7 @@ isActive() { } install() { - [ $# -eq 1 -o $# -eq 2 ] || help + [ $# -eq 1 -o $# -eq 2 ] || usage local name=$1 local disk=${2:-$root/images/${name}.qcow2} @@ -103,7 +103,7 @@ install() { | sed '/^\s*$/d' \ | sort -n \ | tail -1 ) - [ -n "$ip" ] || \ + [ "$ip" ] || \ ip=$( /usr/bin/virsh net-dumpxml $network \ | /usr/bin/xmlstarlet sel -t -m /network/ip -v @address ) ip=${ip%.*}.$(( 1 + ${ip##*.} )) @@ -123,7 +123,7 @@ install() { } view(){ - [ $# -eq 1 ] || help + [ $# -eq 1 ] || usage local domain="$1" if ! doesExist "$domain"; then @@ -141,17 +141,18 @@ view(){ local type=$(get_XML_attribute "$domain" devices/graphics type) local port=$(get_XML_attribute "$domain" devices/graphics port) || true - if [ "$type" != spice -o -z "$port" ]; then + if ! [ "$type" = spice -a "$port" ]; then echo "Error: Could not find a valid Spice server on domain '$domain'." >&2 exit 1 fi /usr/bin/spicec -h 127.0.0.1 -p $port } -command="${1:-}" +[ $# -gt 0 ] || usage +command="$1" shift; case "$command" in install|view) $command "$@";; - *) help + *) usage esac |