Prevent lrzuntar from automatically overwriting existing directories without the -f option being specified.

This commit is contained in:
Con Kolivas 2012-03-10 21:40:12 +11:00
parent 14c3ce2ab4
commit 84e42de8da

11
lrztar
View file

@ -40,6 +40,8 @@ lrzip -h will display lrzip options"
|| { printf "lrztar: no tar in your path\n"; return 1; }
which lrzip &> /dev/null \
|| { printf "lrztar: no lrzip in your path\n"; return 1; }
which lrzcat &> /dev/null \
|| { printf "lrztar: no lrzcat in your path\n"; return 1; }
while getopts w:OS:DqL:nlbgzUTN:p:vfo:dtVhHck x; do
[[ $x == [OtV] ]] && {
printf "lrztar: invalid option for lrztar: %s\n" "$x";
@ -57,11 +59,18 @@ lrzip -h will display lrzip options"
[[ ${s%/*} != $s ]] && i="${s%/*}/" || i="./"
((v_d)) && {
s="${s%/}"
i+="${s##*/}"
s="${s##*/}"
i+="$s"
s="${s%.tar.lrz}"
[[ -e $i ]] || {
printf "lrztar: file does not exist: %s\n" "$i"
return 1
}
! ((v_f)) && [[ -e $s ]] && {
printf "lrztar: $s exists, will not overwrite without -f option\n"
return 1
}
lrzcat "${p[@]}" "$i" | tar x
x=$?
} || {