1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-11-22 04:45:11 +00:00

Use _exit_1 with non-help error messages.

This commit is contained in:
William Melody 2020-05-17 11:28:31 -07:00
parent 8f2553b5a3
commit 1d948837d0
3 changed files with 7 additions and 12 deletions

15
hosts
View File

@ -816,8 +816,7 @@ backups() {
exit 1 exit 1
elif [[ ! -e "${_hosts_dirname}/${_filename}" ]] elif [[ ! -e "${_hosts_dirname}/${_filename}" ]]
then then
printf "Backup not found: %s\\n" "${_filename:-}" _exit_1 printf "Backup not found: %s\\n" "${_filename:-}"
exit 1
fi fi
diff -u "${HOSTS_PATH}" "${_hosts_dirname}/${_filename}" diff -u "${HOSTS_PATH}" "${_hosts_dirname}/${_filename}"
@ -837,8 +836,7 @@ backups() {
rm "${_hosts_dirname}/${_filename:-}" && rm "${_hosts_dirname}/${_filename:-}" &&
printf "Backup deleted: %s\\n" "${_hosts_dirname}/${_filename:-}" printf "Backup deleted: %s\\n" "${_hosts_dirname}/${_filename:-}"
else else
printf "Backup not found: %s\\n" "${_filename:-}" _exit_1 printf "Backup not found: %s\\n" "${_filename:-}"
exit 1
fi fi
;; ;;
restore) restore)
@ -848,8 +846,7 @@ backups() {
exit 1 exit 1
elif [[ ! -e "${_hosts_dirname}/${_filename}" ]] elif [[ ! -e "${_hosts_dirname}/${_filename}" ]]
then then
printf "Backup not found: %s\\n" "${_filename:-}" _exit_1 printf "Backup not found: %s\\n" "${_filename:-}"
exit 1
fi fi
_verify_write_permissions _verify_write_permissions
@ -869,8 +866,7 @@ backups() {
exit 1 exit 1
elif [[ ! -e "${_hosts_dirname}/${_filename}" ]] elif [[ ! -e "${_hosts_dirname}/${_filename}" ]]
then then
printf "Backup not found: %s\\n" "${_filename:-}" _exit_1 printf "Backup not found: %s\\n" "${_filename:-}"
exit 1
fi fi
cat "${_hosts_dirname}/${_filename:-}" cat "${_hosts_dirname}/${_filename:-}"
@ -1279,8 +1275,7 @@ remove() {
if [[ -z "${_target_records:-}" ]] if [[ -z "${_target_records:-}" ]]
then then
printf "No matching records found.\\n" _exit_1 printf "No matching records found.\\n"
exit 1
fi fi
if ! ((_force_skip_prompt)) if ! ((_force_skip_prompt))

View File

@ -53,7 +53,7 @@ load test_helper
run "${_HOSTS}" remove 127.0.0.3 --force run "${_HOSTS}" remove 127.0.0.3 --force
printf "\${status}: %s\\n" "${status}" printf "\${status}: %s\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}" printf "\${output}: '%s'\\n" "${output}"
[[ ${output} == "No matching records found." ]] [[ ${output} == "${_ERROR_PREFIX}No matching records found." ]]
} }
# `hosts remove <ip> --force` ################################################# # `hosts remove <ip> --force` #################################################

View File

@ -49,7 +49,7 @@ load test_helper
run "${_HOSTS}" unblock example.net run "${_HOSTS}" unblock example.net
printf "\${status}: %s\\n" "${status}" printf "\${status}: %s\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}" printf "\${output}: '%s'\\n" "${output}"
[[ ${output} == "No matching records found." ]] [[ ${output} == "${_ERROR_PREFIX}No matching records found." ]]
} }
# `hosts unblock <hostname>` ########################################### # `hosts unblock <hostname>` ###########################################