1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-11-21 20:35:10 +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
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))

View File

@ -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 <ip> --force` #################################################

View File

@ -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 <hostname>` ###########################################