Project

General

Profile

1
#!/bin/bash -e
2
. "$(dirname "${BASH_SOURCE[0]}")"/util.sh
3

    
4
if self_not_included; then
5

    
6
alias use_sync='declare prefix=sync_; import_vars; unset prefix'
7

    
8
upload() #usage: local_dir=... remote_url=serv:dir [swap=1] upload [opt|path]...
9
# swap: downloads instead of uploads
10
# requires put from https://uutils.googlecode.com/svn/trunk/bin/put
11
{
12
	echo_func; kw_params local_dir remote_url; echo_vars swap
13
	
14
	# change path args to --includes
15
	local has_includes= args=()
16
	local a; for a in "$@"; do
17
		if starts_with -- "$a"; then args+=("$a") # option, so leave as is
18
		else # path
19
			# also need to --include parent dirs for each --include path
20
			path_parents "$(base_dir="$local_dir" canon_rel_path "$a")"
21
			args+=("${dirs[@]/#/--include=/}") # prepend each with --include=/
22
			has_includes=1
23
		fi
24
	done
25
	set -- "${args[@]}" ${has_includes:+--exclude="**"}
26
	
27
	# use .rsync_ignore
28
	set -- --filter="dir-merge,- .rsync_ignore" "$@"
29
	
30
	src="$local_dir" dest="$remote_url" command put "$@"
31
}
32

    
33
fi
(8-8/10)