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

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