Handle directories as destination paths. Fixes #294.

This commit is contained in:
Pedro Algarvio 2014-02-16 19:19:39 +00:00
parent fdc48ee6bf
commit 65f1f63c81

View file

@ -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"