diff options
author | Jonathan Bauer | 2013-03-01 15:54:43 +0100 |
---|---|---|
committer | Jonathan Bauer | 2013-03-01 15:54:43 +0100 |
commit | bb810e477dd1c2be7ead1faff69f5f5d5218f103 (patch) | |
tree | ab9ef3a695c839ba6cd34302a963837875705a29 /helper/fileutil.inc | |
parent | some minor fixes (diff) | |
download | tm-scripts-bb810e477dd1c2be7ead1faff69f5f5d5218f103.tar.gz tm-scripts-bb810e477dd1c2be7ead1faff69f5f5d5218f103.tar.xz tm-scripts-bb810e477dd1c2be7ead1faff69f5f5d5218f103.zip |
tarcopy: check for destination directory else create it
Diffstat (limited to 'helper/fileutil.inc')
-rw-r--r-- | helper/fileutil.inc | 1 |
1 files changed, 1 insertions, 0 deletions
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]})" |