Added author notices.
[rpush-cat.git] / rpush-into
blob45e39839ff5bdf1e71c5ebc9ed048afe5d2e2628
1 #!/bin/bash
3 # Usage:
4 # rpush-into [-c|--continue|-f|--force] FILE REMOTE_PREFIX ssh SSH_args..
5 # or
6 # rpush-into [-c|--continue|-f|--force] FILE REMOTE_PREFIX eval
8 # On carefulness:
9 # will try not to overwrite files on the remote side unless -f is specified.
10 # With -c, if a files exists, this script will continue the transfer by appending.
12 # REMOTE_PREFIX can be a directory (terminated with /!),
13 # or another prefix that will prepended to FILE to get
14 # the path to the destination file on the remote end.
16 # It can be an empty string (''):
17 # then--obviously--FILE will be put into the remote home directory
18 # (or rather the current directory after connection to the remote end).
20 # "ssh" and "eval" are just examples; any valid bash command
21 # which interpretes arguments in the same way as "eval" will do.
23 # Licensed to all under AGPL as published by FSF.
24 # Copyright (C) 2012 by Ivan Zakharyaschev imz at altlinux.org
26 case "$1" in
27 -c|--continue)
28 shift
29 RPUSH() {
30 rpush "$@" || rpush-continue "$@"
33 -f|--force)
34 shift
35 RPUSH() {
36 rpush -f "$@"
40 RPUSH() {
41 rpush "$@"
44 esac
46 FILE="$1"
47 shift
48 REMOTE_PREFIX="$1"
49 shift
51 RPUSH "$FILE" "$REMOTE_PREFIX$(basename "$FILE")" "$@"