diff --git a/files/archive-files b/files/archive-files index 540b4d5..9bf079d 100755 --- a/files/archive-files +++ b/files/archive-files @@ -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 to quit$Z\n" -read foo +if [[ $YES -eq 0 ]]; then + printf "$S to quit$Z\n" + read foo +fi set -o pipefail SIZE=$( find "${REALFILES[@]}" -type f -printf %s"\n" | count_size ) diff --git a/files/archive-subfolders b/files/archive-subfolders index 5374849..232f5ae 100755 --- a/files/archive-subfolders +++ b/files/archive-subfolders @@ -9,6 +9,7 @@ function helpexit() { echo "Usage: $BS [-z/-n/--rm] [folder name(s)]" echo " -z Compress." echo " -n No compression. [default]" + echo " -y Dont ask before starting the archival." echo " --nl Do not store a separate file list." echo " --rm Remove source folders after archival." echo " folder name: If given, archive only the named folder(s)." @@ -65,10 +66,12 @@ DEPTH=1 FOLDERS=( ) REMOVE=0 KEEP_LIST=1 +YES=0 for ((i=1; i<=${#@}; i++)) { [[ "${!i}" = "-h" ]] && helpexit [[ "${!i}" = "--help" ]] && helpexit [[ "${!i}" = "-n" ]] && { continue; } # obsolete behaviour + [[ "${!i}" = "-y" ]] && { YES=1; continue; } [[ "${!i}" = "-z" ]] && { COMPRESSION=1; NOCOMPRESSION=0; COMPRESSCMD="| gzip"; SUFFIX=tgz; continue; } [[ "${!i}" = "--nl" ]] && { KEEP_LIST=0; continue; } [[ "${!i}" = "--rm" ]] && { REMOVE=1; continue; } @@ -91,8 +94,10 @@ echo -n $S"Archive the following folders " } echo $Z for folder in "${REALFOLDERS[@]}"; do echo "'$folder'"; done -printf "$S to quit$Z\n" -read foo +if [[ $YES -eq 0 ]]; then + printf "$S to quit$Z\n" + read foo +fi set -o pipefail for d in "${REALFOLDERS[@]}"; do