fix _make_git_tar_dir.sh - don't 'append directory' to symlinks
[cmdllinux.git] / scripts / _tar_xz_files3.sh
blobc30e42c5d7e0661b8e6686c0482d71c9a87c0273
1 #tar xz targzs to destination
3 untargz()
5 while read targz_file; do
6 tar xzf "$targz_file" -C "$DIR_DST" 2> /dev/null
7 retval=$?
8 #2 return code (value) (error) eg.: overwriting an existing directory with symbolic link
9 if [ "$retval" = 2 ]; then
10 tar tzf "$targz_file" | grep -v "/$" | \
11 while read file; do
12 #[ -d "$DIR_DST"/"$file" -a ! -L "$DIR_DST"/"$file" ] && echo "$file"
13 [ -d "$DIR_DST"/"$file" -a ! -L "$DIR_DST"/"$file" ] && rm -rf "$DIR_DST"/"$file"
14 done
15 tar xzf "$targz_file" -C "$DIR_DST" 2> /dev/null
17 done < /dev/stdin
20 if [ "$#" = 3 ]; then
21 TGZ="$1"
22 shift
25 DIR_SRC="$1"
26 DIR_DST="$2"
28 [ ! -d "$DIR_SRC" ] && echo "No such source directory" && exit 1
29 [ ! -d "$DIR_DST" ] && echo "No such destination directory" && exit 1
31 DIR_DST=`cd "$DIR_DST" && pwd -P`
32 [ "$?" != 0 ] && echo "Cannot change to destination directory" && exit 1
34 cd "$DIR_SRC"
35 [ "$?" != 0 ] && echo "Cannot change to source directory" && exit 1
37 if [ -n "$TGZ" ]; then
38 echo "$TGZ" | untargz
39 else
40 ls *.tar.gz 2> /dev/null | untargz