handle case when file and dest have same basenames

This commit is contained in:
illiliti 2020-09-08 23:32:54 +03:00
parent 9ca7b1c590
commit 36435d6773

View File

@ -155,15 +155,17 @@ copy_file()
# iterate throught symlinks and copy them
while [ -h "$file" ]; do
cp -P "$file" "${tmpdir}${dest}" || panic
cp -P "$file" "${tmpdir}${dest%/*}/${file##*/}"
cd -P "${file%/*}"
symlink=$(ls -ld "$file")
symlink="${symlink##* -> }"
file="${PWD}/${symlink##*/}"
done
# handle case when file and dest have same basenames
[ -h "${tmpdir}${dest}" ] && dest="${dest%/*}/${file##*/}"
{
cp "$file" "${tmpdir}${dest}"
chmod "$mode" "${tmpdir}${dest}"