summaryrefslogblamecommitdiffstats
path: root/helper/fileutil.inc
blob: 40bc42d56c744e48c5b9003c4d37410d141d2b4a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                                                                          
# copy list of files using tar
tarcopy () {
	[ $# -ne 2 ] && perror "Sanity check failed: tarcopy needs exactly two params, but $# were given."
	if [ -z $1 ]; then
		pwarning "tarcopy called with empty input list (dest was '$2')"
		return
	fi
	local SHORT=$1
	[ ${#SHORT} -gt 18 ] && SHORT=$(echo "$SHORT" | cut -c-13)...$(echo "$SHORT" | cut -c${#SHORT}-)
	[ -z $2 ] && perror "tarcopy called with empty destination."
	tar -cp "$1" | tar -xp -C "$2"
	local PS1=$PIPESTATUS[0]
	local PS2=$PIPESTATUS[1]
	[ $PS1 -ne 0 ] && perror "packing-part of tar-copy from '$SHORT' to '$2' failed."
	[ $PS2 -ne 0 ] && perror "unpacking-part of tar-copy from '$SHORT' to '$2' failed."
}