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