4 # rpush-continue SRC [--android|--unix] DEST ssh SSH_args..
6 # rpush-continue SRC [--android|--unix] DEST eval
9 # DEST on the remote side will be appended to without questions!
11 # If DEST on the remote side doesn't exist, we'll probably exit immediately.
13 # "ssh" and "eval" are just examples; any valid bash command
14 # which interpretes arguments in the same way as "eval" will do.
16 # --android or --unix switches the pattern for reading the size from
17 # the output of "ls -l" (either on Android 2.2 or usual Unix, GNU/Linux).
18 # By default, we assume you are connecting to an Android (with DroidSSHd).
20 # Licensed to all under AGPL as published by FSF.
21 # Copyright (C) 2012 by Ivan Zakharyaschev imz at altlinux.org
29 readonly readSizeRemote
=readSizeUnixls
33 readonly readSizeRemote
=readSizeAndroidls
36 readonly readSizeRemote
=readSizeAndroidls
59 # The columns of "ls -l" output on GNU/Linux:
60 local perms links user group size rest
61 read perms links user group size rest \
66 # "ls -l" output on Android 2.2 (Galaxy S) misses one column:
67 local perms user group size rest
68 read perms user group size rest \
72 # Other (non)possibilities to get the size of a file:
73 # * "ls -s" is in blocks, but I want bytes;
74 # * "stat" is missing on Android (2.2).
76 # If SRC doesn't exist, we'll exit before doing anything else.
77 SRCsize
="$(ls -l "$SRC" | readSizeUnixls)" ||
exit $?
79 datapipe
="$(mktemp --dry-run)"
86 # TODO: the problem here: the value $DEST should be protected from an expansion by the remote shell.
87 RSH
"$@" "ls -l $DEST && cat >> $DEST" < "$datapipe" | \
89 DESTsize
="$($readSizeRemote)" ||
exit $?
90 tail -c +$
((DESTsize
+1)) "$SRC" | pv
--wait --size $
((SRCsize-DESTsize
))