From 198e6c944f23cd911766d64b0409ddf2daa485f5 Mon Sep 17 00:00:00 2001 From: framp Date: Sat, 23 May 2020 11:40:53 +0200 Subject: [PATCH] Remove zip extension in target --- pishrink.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pishrink.sh b/pishrink.sh index ce8754b..1e17bdd 100755 --- a/pishrink.sh +++ b/pishrink.sh @@ -160,15 +160,19 @@ done #Copy to new file if requested if [ -n "$2" ]; then - info "Copying $1 to $2..." - cp --reflink=auto --sparse=always "$1" "$2" + f="$2" + if [[ -n $ziptool && "${f##*.}" == ${ZIPEXTENSIONS[$ziptool]} ]]; then # remove zip extension if zip requested because zip tool will complain about extension + f="${f%.*}" + fi + info "Copying $1 to $f..." + cp --reflink=auto --sparse=always "$1" "$f" if (( $? != 0 )); then error $LINENO "Could not copy file..." exit -5 fi old_owner=$(stat -c %u:%g "$1") - chown "$old_owner" "$2" - img="$2" + chown "$old_owner" "$f" + img="$f" fi # cleanup at script exit