mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0029-p2v-tests-Fix-fake-scp-command-so-it-can-handle-mult.patch

151578
From f06fc3401bc88206502f6f876a553634c8acf220 Mon Sep 17 00:00:00 2001
151578
From: "Richard W.M. Jones" <rjones@redhat.com>
151578
Date: Thu, 30 Mar 2017 19:34:29 +0100
151578
Subject: [PATCH] p2v: tests: Fix fake scp command so it can handle multiple
151578
 local files.
151578
151578
Fixes commit d178deeeb814471b9d70431626b6cd515a21d0c1.
151578
151578
(cherry picked from commit b417c877f4ea848af8f8538957ab677c65637027)
151578
---
151578
 p2v/test-virt-p2v-scp.sh | 16 ++++++++++------
151578
 1 file changed, 10 insertions(+), 6 deletions(-)
151578
151578
diff --git a/p2v/test-virt-p2v-scp.sh b/p2v/test-virt-p2v-scp.sh
151578
index c8a405db4..29900b663 100755
151578
--- a/p2v/test-virt-p2v-scp.sh
151578
+++ b/p2v/test-virt-p2v-scp.sh
151578
@@ -44,15 +44,19 @@ while true ; do
151578
     esac
151578
 done
151578
 
151578
-# Hopefully there are two arguments left, the source (local) file
151578
-# and a remote file of the form user@server:remote.
151578
-if [ $# -ne 2 ]; then
151578
+# Hopefully there are >= two arguments left, the source (local)
151578
+# file(s) and a remote file of the form user@server:remote.
151578
+if [ $# -lt 2 ]; then
151578
     echo "$0: incorrect number of arguments found:" "$@"
151578
     exit 1
151578
 fi
151578
 
151578
-local="$1"
151578
-remote="$(echo $2 | awk -F: '{print $2}')"
151578
+# https://stackoverflow.com/questions/1853946/getting-the-last-argument-passed-to-a-shell-script/1854031#1854031
151578
+remote="${@: -1}"
151578
+# https://stackoverflow.com/questions/20398499/remove-last-argument-from-argument-list-of-shell-script-bash/26163980#26163980
151578
+set -- "${@:1:$(($#-1))}"
151578
+
151578
+remote="$(echo $remote | awk -F: '{print $2}')"
151578
 
151578
 # Use the copy command.
151578
-exec cp "$local" "$remote"
151578
+exec cp "$@" "$remote"
151578
-- 
151578
2.14.3
151578