archive tools with -y switch to answer yes

This commit is contained in:
Q
2020-01-12 23:18:15 +02:00
parent 473b337a38
commit 045106a3a5
2 changed files with 14 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ function helpexit() {
echo "Usage: $BS [-z/-n/--rm]"
echo " -z Compress."
echo " -n No compression. [default]"
echo " -y Dont ask before starting the archival."
echo " --rm Remove source folders after archival."
exit
@@ -59,9 +60,11 @@ NOCOMPRESSION=1
COMPRESSION=0
SUFFIX=tar
REMOVE=0
YES=0
for ((i=1; i<=${#@}; i++)) {
[[ "${!i}" = "-h" ]] && helpexit
[[ "${!i}" = "--help" ]] && helpexit
[[ "${!i}" = "-y" ]] && { YES=1; continue; }
[[ "${!i}" = "-z" ]] && { COMPRESSION=1; NOCOMPRESSION=0; COMPRESSCMD="| gzip"; SUFFIX=tgz; continue; }
[[ "${!i}" = "--rm" ]] && { REMOVE=1; continue; }
[[ "${!i}" = "-"* ]] && helpexit
@@ -83,8 +86,10 @@ echo -n $S"Archive the following files to '$archive_name' "
}
echo $Z
for file in "${REALFILES[@]}"; do echo "'$file'"; done
printf "$S<ctrl-c> to quit$Z\n"
read foo
if [[ $YES -eq 0 ]]; then
printf "$S<ctrl-c> to quit$Z\n"
read foo
fi
set -o pipefail
SIZE=$( find "${REALFILES[@]}" -type f -printf %s"\n" | count_size )