Added author notices.
[rpush-cat.git] / rpush
blob8ed9ec27c7e126ff3c5e229c2fe3d46bc3d1b7cb
1 #!/bin/bash
3 # Usage:
4 # rpush [-f|--force] SRC DEST ssh SSH_args..
5 # or
6 # rpush [-f|--force] SRC DEST eval
8 # On carefulness:
9 # will try not to overwrite DEST unless -f is specified.
11 # "ssh" and "eval" are just examples; any valid bash command
12 # which interpretes arguments in the same way as "eval" will do.
14 # Licensed to all under AGPL as published by FSF.
15 # Copyright (C) 2012 by Ivan Zakharyaschev imz at altlinux.org
17 CHECK=yes
18 case "$1" in
19 -f|--force)
20 CHECK=
21 shift
23 esac
25 readonly SRC="$1"
26 shift
27 readonly DEST="$1"
28 shift
30 readonly RSH="$1"
31 shift
32 case "$RSH" in
33 ssh)
34 RSH() {
35 ssh -e none "$@"
39 RSH() {
40 "$RSH" "$@"
43 esac
45 pv --wait "$SRC" | RSH "$@" "${CHECK:+"ls -l $DEST >&2 2>/dev/null && exit 1 || "}" "cat > $DEST"
46 # TODO: the problem here: the value $DEST should be protected from an expansion by the remote shell.