From a541f2e8717235c0369744fa8e344f59fb4a90c5 Mon Sep 17 00:00:00 2001 From: Nathaniel Landau Date: Sat, 27 Feb 2016 22:58:09 -0500 Subject: [PATCH] Fixed IFS --- bin/trash | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/bin/trash b/bin/trash index 7acff19..ef8466d 100755 --- a/bin/trash +++ b/bin/trash @@ -488,11 +488,44 @@ function header() { local _message="========== ${*} ========== "; echo "$(_ # Log messages when verbose is set to "true" verbose() { if ${verbose}; then debug "$@"; fi } +function seek_confirmation() { + # echo "" + input "$@" + if [[ "${force}" == "1" ]]; then + notice "Forcing confirmation with '--force' flag set" + else + read -p " (y/n) " -n 1 + echo "" + fi +} + +function is_confirmed() { + if [[ "${force}" == "1" ]]; then + return 0 + else + if [[ "${REPLY}" =~ ^[Yy]$ ]]; then + return 0 + fi + return 1 + fi +} + +function is_not_confirmed() { + if [[ "${force}" == "1" ]]; then + return 1 + else + if [[ "${REPLY}" =~ ^[Nn]$ ]]; then + return 0 + fi + return 1 + fi +} + # Trap bad exits with your cleanup function trap trapCleanup EXIT INT TERM # Set IFS to preferred implementation -IFS=$'\n\t' +IFS=$' \n\t' # Exit on error. Append '||true' when you run the script if you expect an error. set -o errexit