From bb810e477dd1c2be7ead1faff69f5f5d5218f103 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 1 Mar 2013 15:54:43 +0100 Subject: tarcopy: check for destination directory else create it --- helper/fileutil.inc | 1 + 1 file changed, 1 insertion(+) (limited to 'helper') diff --git a/helper/fileutil.inc b/helper/fileutil.inc index 087a9a7f..1a5befbd 100644 --- a/helper/fileutil.inc +++ b/helper/fileutil.inc @@ -23,6 +23,7 @@ tarcopy () { local SHORT=$FROM [ ${#SHORT} -gt 23 ] && SHORT=$(echo "$SHORT" | cut -c-18)...$(echo "$SHORT" | cut -c$[${#SHORT} - 4]-) [ -z "$TO" ] && perror "tarcopy called with empty destination." + [ ! -d "$TO" ] && { mkdir -p "$TO" || perror "could not create destination "$TO" for tar-copy."; } tar -cp $FROM | tar -xp -C "$TO" local PS=(${PIPESTATUS[*]}) [ "x${PS[0]}" != "x0" ] && perror "packing-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[0]})" -- cgit v1.2.3-55-g7522