From 1d948837d0ac2047e46b333a3ebef5748c9bd893 Mon Sep 17 00:00:00 2001 From: William Melody Date: Sun, 17 May 2020 11:28:31 -0700 Subject: [PATCH] Use `_exit_1` with non-help error messages. --- hosts | 15 +++++---------- test/remove.bats | 2 +- test/unblock.bats | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/hosts b/hosts index bc95407..7f4493e 100755 --- a/hosts +++ b/hosts @@ -816,8 +816,7 @@ backups() { exit 1 elif [[ ! -e "${_hosts_dirname}/${_filename}" ]] then - printf "Backup not found: %s\\n" "${_filename:-}" - exit 1 + _exit_1 printf "Backup not found: %s\\n" "${_filename:-}" fi diff -u "${HOSTS_PATH}" "${_hosts_dirname}/${_filename}" @@ -837,8 +836,7 @@ backups() { rm "${_hosts_dirname}/${_filename:-}" && printf "Backup deleted: %s\\n" "${_hosts_dirname}/${_filename:-}" else - printf "Backup not found: %s\\n" "${_filename:-}" - exit 1 + _exit_1 printf "Backup not found: %s\\n" "${_filename:-}" fi ;; restore) @@ -848,8 +846,7 @@ backups() { exit 1 elif [[ ! -e "${_hosts_dirname}/${_filename}" ]] then - printf "Backup not found: %s\\n" "${_filename:-}" - exit 1 + _exit_1 printf "Backup not found: %s\\n" "${_filename:-}" fi _verify_write_permissions @@ -869,8 +866,7 @@ backups() { exit 1 elif [[ ! -e "${_hosts_dirname}/${_filename}" ]] then - printf "Backup not found: %s\\n" "${_filename:-}" - exit 1 + _exit_1 printf "Backup not found: %s\\n" "${_filename:-}" fi cat "${_hosts_dirname}/${_filename:-}" @@ -1279,8 +1275,7 @@ remove() { if [[ -z "${_target_records:-}" ]] then - printf "No matching records found.\\n" - exit 1 + _exit_1 printf "No matching records found.\\n" fi if ! ((_force_skip_prompt)) diff --git a/test/remove.bats b/test/remove.bats index 0af4f4b..37924f0 100644 --- a/test/remove.bats +++ b/test/remove.bats @@ -53,7 +53,7 @@ load test_helper run "${_HOSTS}" remove 127.0.0.3 --force printf "\${status}: %s\\n" "${status}" printf "\${output}: '%s'\\n" "${output}" - [[ ${output} == "No matching records found." ]] + [[ ${output} == "${_ERROR_PREFIX}No matching records found." ]] } # `hosts remove --force` ################################################# diff --git a/test/unblock.bats b/test/unblock.bats index e829289..54aad35 100644 --- a/test/unblock.bats +++ b/test/unblock.bats @@ -49,7 +49,7 @@ load test_helper run "${_HOSTS}" unblock example.net printf "\${status}: %s\\n" "${status}" printf "\${output}: '%s'\\n" "${output}" - [[ ${output} == "No matching records found." ]] + [[ ${output} == "${_ERROR_PREFIX}No matching records found." ]] } # `hosts unblock ` ###########################################