Sfoglia il codice sorgente

Merge remote-tracking branch 'qubesos/pr/11'

* qubesos/pr/11:
  Properly handle case of empty domain name.
  Use proper quoting around variables.
  Move usage information printing to separate function, and print usage to stderr; also added some spacing.
  Use proper space-expanded tabs, as per the coding guidelines.
Marek Marczykowski-Górecki 8 anni fa
parent
commit
f7d7c6125e
1 ha cambiato i file con 16 aggiunte e 7 eliminazioni
  1. 16 7
      qubes-rpc/qvm-run

+ 16 - 7
qubes-rpc/qvm-run

@@ -20,8 +20,8 @@
 #
 #
 
-if [ $# -lt 2 ] ; then
-	cat <<USAGE
+function print_usage(){
+cat >&2 <<USAGE
 Usage: $0 vmname command arguments
 Executes a command in another VM using the qubes.VMShell RPC service.  The
 arguments are joined with spaces and passed to "bash -c".
@@ -33,11 +33,20 @@ is your terminal.
 
 You can use \$dispvm or --dispvm instead of vmname to start a new DisposableVM.
 USAGE
-	exit 1
+}
+
+if [ $# -lt 2 ] ; then
+    print_usage
+    exit 1
 fi
-VMNAME=$1
+
+VMNAME="$1"
 shift
-if [ $VMNAME = "--dispvm" ] ; then
-	VMNAME='$dispvm'
+
+if [ "$VMNAME" = "--dispvm" ] ; then
+    VMNAME='$dispvm'
+elif [ "$VMNAME" = "" ] ; then
+    print_usage
+    exit 1
 fi
-exec /usr/lib/qubes/qrexec-client-vm $VMNAME qubes.VMShell "/usr/lib/qubes/qrun-in-vm" "$@"
+exec /usr/lib/qubes/qrexec-client-vm "$VMNAME" qubes.VMShell "/usr/lib/qubes/qrun-in-vm" "$@"