reworked path handling...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-12-30 18:37:35 +03:00
parent 551da5ded3
commit 6fb0002145
2 changed files with 17 additions and 3 deletions

View File

@ -126,6 +126,18 @@ hostname2ct(){
}
#----------------------------------------------------------------------
normpath(){
echo $1 \
| sed \
-e 's/\/\+/\//g' \
-e 's/\/.\//\//g' \
-e 's/[^\/]\+\/\.\.//g' \
-e 's/\/\+/\//g' \
-e 's/\/\.$/\//g'
}
#----------------------------------------------------------------------
# vim:set ts=4 sw=4 nowrap :

View File

@ -34,7 +34,7 @@ to=$3
# get from path relative to working directory...
if [[ ${from:0:1} != '/' ]] ; then
from="$(pwd)/${from}"
from="$(normpath "$(pwd)/${from}")"
fi
@ -52,9 +52,11 @@ done
local files=($(find "$from" -type f))
for file in "${files[@]}" ; do
file=${file#${from}}
f=$(normpath "${from}/${file}")
t=$(normpath "${to}/${file}")
[ $QUIET ] \
|| echo "copy: \"${from}/${file}\" -> $id:\"${to}/${file}\""
pct push $id "${from}/${file}" "${to}/${file}"
|| echo "copy: \"$f\" -> $id:\"$t\""
pct push $id "$f" "$t"
done