diff options
Diffstat (limited to 'localsyncthis')
-rwxr-xr-x | localsyncthis | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/localsyncthis b/localsyncthis index c1c0346..99b68f3 100755 --- a/localsyncthis +++ b/localsyncthis @@ -79,17 +79,28 @@ fi while [ -n "$workdir" ]; do for host in $hosts; do + thisdir="$localdir$workdir" thatdir="$remotedir$workdir" + shellmagic="" + + if [ -z "$localdir" ] && echo "$host" | grep -q '@'; then + relativeworkdir=$(echo "$workdir" | sed "s|^$HOME/\?||") + if [ "$workdir" != "$relativeworkdir" ]; then + thisdir="$workdir" + thatdir="$relativeworkdir" + shellmagic="~/" + fi + fi case $action in download) - rsync --rsh="ssh $ssh_opts" $rsync_opts "$host:'$thatdir/'" "$thisdir" - [ $V ] && echo rsync --rsh="ssh $ssh_opts" $rsync_opts "$host:'$thatdir/'" "$thisdir" + [ $V ] && echo rsync --rsh="ssh $ssh_opts" $rsync_opts "$host:$shellmagic'$thatdir/'" "$thisdir" + rsync --rsh="ssh $ssh_opts" $rsync_opts "$host:$shellmagic'$thatdir/'" "$thisdir" ;; upload) - rsync --rsh="ssh $ssh_opts" $rsync_opts "$thisdir/" "$host:'$thatdir'" - [ $V ] && echo rsync --rsh="ssh $ssh_opts" $rsync_opts "$thisdir/" "$host:'$thatdir'" + [ $V ] && echo rsync --rsh="ssh $ssh_opts" $rsync_opts "$thisdir/" "$host:$shellmagic'$thatdir'" + rsync --rsh="ssh $ssh_opts" $rsync_opts "$thisdir/" "$host:$shellmagic'$thatdir'" ;; *) echo "$prg error: You need to specify either --upload or --download!" echo |