From 65f1f63c81642ab4b70ad829d877e567e6911df1 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 16 Feb 2014 19:19:39 +0000 Subject: [PATCH] Handle directories as destination paths. Fixes #294. --- bootstrap-salt.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index b265cc2..4ea6b41 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -1170,6 +1170,14 @@ copyfile() { return 1 fi + # If the destination is a directory, let's make it a full path so the logic + # below works as expected + if [ -d "$dfile" ]; then + echodebug "The passed destination($dfile) is a directory" + dfile="${dfile}/$(basename $sfile)" + echodebug "Full destination path is now: $dfile" + fi + if [ ! -f "$dfile" ]; then # The destination file does not exist, copy echodebug "Copying $sfile to $dfile" @@ -1218,6 +1226,14 @@ movefile() { return 1 fi + # If the destination is a directory, let's make it a full path so the logic + # below works as expected + if [ -d "$dfile" ]; then + echodebug "The passed destination($dfile) is a directory" + dfile="${dfile}/$(basename $sfile)" + echodebug "Full destination path is now: $dfile" + fi + if [ ! -f "$dfile" ]; then # The destination file does not exist, copy echodebug "Moving $sfile to $dfile"