archive tools with -y switch to answer yes
This commit is contained in:
@@ -9,6 +9,7 @@ function helpexit() {
|
|||||||
echo "Usage: $BS [-z/-n/--rm]"
|
echo "Usage: $BS [-z/-n/--rm]"
|
||||||
echo " -z Compress."
|
echo " -z Compress."
|
||||||
echo " -n No compression. [default]"
|
echo " -n No compression. [default]"
|
||||||
|
echo " -y Dont ask before starting the archival."
|
||||||
echo " --rm Remove source folders after archival."
|
echo " --rm Remove source folders after archival."
|
||||||
|
|
||||||
exit
|
exit
|
||||||
@@ -59,9 +60,11 @@ NOCOMPRESSION=1
|
|||||||
COMPRESSION=0
|
COMPRESSION=0
|
||||||
SUFFIX=tar
|
SUFFIX=tar
|
||||||
REMOVE=0
|
REMOVE=0
|
||||||
|
YES=0
|
||||||
for ((i=1; i<=${#@}; i++)) {
|
for ((i=1; i<=${#@}; i++)) {
|
||||||
[[ "${!i}" = "-h" ]] && helpexit
|
[[ "${!i}" = "-h" ]] && helpexit
|
||||||
[[ "${!i}" = "--help" ]] && helpexit
|
[[ "${!i}" = "--help" ]] && helpexit
|
||||||
|
[[ "${!i}" = "-y" ]] && { YES=1; continue; }
|
||||||
[[ "${!i}" = "-z" ]] && { COMPRESSION=1; NOCOMPRESSION=0; COMPRESSCMD="| gzip"; SUFFIX=tgz; continue; }
|
[[ "${!i}" = "-z" ]] && { COMPRESSION=1; NOCOMPRESSION=0; COMPRESSCMD="| gzip"; SUFFIX=tgz; continue; }
|
||||||
[[ "${!i}" = "--rm" ]] && { REMOVE=1; continue; }
|
[[ "${!i}" = "--rm" ]] && { REMOVE=1; continue; }
|
||||||
[[ "${!i}" = "-"* ]] && helpexit
|
[[ "${!i}" = "-"* ]] && helpexit
|
||||||
@@ -83,8 +86,10 @@ echo -n $S"Archive the following files to '$archive_name' "
|
|||||||
}
|
}
|
||||||
echo $Z
|
echo $Z
|
||||||
for file in "${REALFILES[@]}"; do echo "'$file'"; done
|
for file in "${REALFILES[@]}"; do echo "'$file'"; done
|
||||||
|
if [[ $YES -eq 0 ]]; then
|
||||||
printf "$S<ctrl-c> to quit$Z\n"
|
printf "$S<ctrl-c> to quit$Z\n"
|
||||||
read foo
|
read foo
|
||||||
|
fi
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
SIZE=$( find "${REALFILES[@]}" -type f -printf %s"\n" | count_size )
|
SIZE=$( find "${REALFILES[@]}" -type f -printf %s"\n" | count_size )
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ function helpexit() {
|
|||||||
echo "Usage: $BS [-z/-n/--rm] [folder name(s)]"
|
echo "Usage: $BS [-z/-n/--rm] [folder name(s)]"
|
||||||
echo " -z Compress."
|
echo " -z Compress."
|
||||||
echo " -n No compression. [default]"
|
echo " -n No compression. [default]"
|
||||||
|
echo " -y Dont ask before starting the archival."
|
||||||
echo " --nl Do not store a separate file list."
|
echo " --nl Do not store a separate file list."
|
||||||
echo " --rm Remove source folders after archival."
|
echo " --rm Remove source folders after archival."
|
||||||
echo " folder name: If given, archive only the named folder(s)."
|
echo " folder name: If given, archive only the named folder(s)."
|
||||||
@@ -65,10 +66,12 @@ DEPTH=1
|
|||||||
FOLDERS=( )
|
FOLDERS=( )
|
||||||
REMOVE=0
|
REMOVE=0
|
||||||
KEEP_LIST=1
|
KEEP_LIST=1
|
||||||
|
YES=0
|
||||||
for ((i=1; i<=${#@}; i++)) {
|
for ((i=1; i<=${#@}; i++)) {
|
||||||
[[ "${!i}" = "-h" ]] && helpexit
|
[[ "${!i}" = "-h" ]] && helpexit
|
||||||
[[ "${!i}" = "--help" ]] && helpexit
|
[[ "${!i}" = "--help" ]] && helpexit
|
||||||
[[ "${!i}" = "-n" ]] && { continue; } # obsolete behaviour
|
[[ "${!i}" = "-n" ]] && { continue; } # obsolete behaviour
|
||||||
|
[[ "${!i}" = "-y" ]] && { YES=1; continue; }
|
||||||
[[ "${!i}" = "-z" ]] && { COMPRESSION=1; NOCOMPRESSION=0; COMPRESSCMD="| gzip"; SUFFIX=tgz; continue; }
|
[[ "${!i}" = "-z" ]] && { COMPRESSION=1; NOCOMPRESSION=0; COMPRESSCMD="| gzip"; SUFFIX=tgz; continue; }
|
||||||
[[ "${!i}" = "--nl" ]] && { KEEP_LIST=0; continue; }
|
[[ "${!i}" = "--nl" ]] && { KEEP_LIST=0; continue; }
|
||||||
[[ "${!i}" = "--rm" ]] && { REMOVE=1; continue; }
|
[[ "${!i}" = "--rm" ]] && { REMOVE=1; continue; }
|
||||||
@@ -91,8 +94,10 @@ echo -n $S"Archive the following folders "
|
|||||||
}
|
}
|
||||||
echo $Z
|
echo $Z
|
||||||
for folder in "${REALFOLDERS[@]}"; do echo "'$folder'"; done
|
for folder in "${REALFOLDERS[@]}"; do echo "'$folder'"; done
|
||||||
|
if [[ $YES -eq 0 ]]; then
|
||||||
printf "$S<ctrl-c> to quit$Z\n"
|
printf "$S<ctrl-c> to quit$Z\n"
|
||||||
read foo
|
read foo
|
||||||
|
fi
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
for d in "${REALFOLDERS[@]}"; do
|
for d in "${REALFOLDERS[@]}"; do
|
||||||
|
|||||||
Reference in New Issue
Block a user