mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-27 23:36:35 +00:00
Use explicit escaping for "\\n" newlines.
Backslash is literal, so explicitly escape it rather than rely on fallback behavior. ShellCheck SC1117 https://github.com/koalaman/shellcheck/wiki/SC1117
This commit is contained in:
parent
b242081ef1
commit
80edd464b6
122
hosts
122
hosts
@ -63,18 +63,18 @@ export _TAB_SPACE_CC_="[${_TAB_SPACE_}]"
|
||||
# _debug()
|
||||
#
|
||||
# Usage:
|
||||
# _debug printf "Debug info. Variable: %s\n" "$0"
|
||||
# _debug printf "Debug info. Variable: %s\\n" "$0"
|
||||
#
|
||||
# A simple function for executing a specified command if the `$_USE_DEBUG`
|
||||
# variable has been set. The command is expected to print a message and
|
||||
# should typically be either `echo`, `printf`, or `cat`.
|
||||
_debug() {
|
||||
if [[ "${_USE_DEBUG:-"0"}" -eq 1 ]]
|
||||
then
|
||||
then
|
||||
# Prefix debug message with "bug (U+1F41B)"
|
||||
printf "🐛 "
|
||||
"${@}"
|
||||
printf "――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――\n"
|
||||
printf "――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――\\n"
|
||||
fi
|
||||
}
|
||||
# debug()
|
||||
@ -96,7 +96,7 @@ debug() {
|
||||
# _die()
|
||||
#
|
||||
# Usage:
|
||||
# _die printf "Error message. Variable: %s\n" "$0"
|
||||
# _die printf "Error message. Variable: %s\\n" "$0"
|
||||
#
|
||||
# A simple function for exiting with an error after executing the specified
|
||||
# command. The command is expected to print a message and should typically
|
||||
@ -264,16 +264,16 @@ _COMMAND_PARAMETERS=(${_COMMAND_ARGV[*]})
|
||||
unset "_COMMAND_PARAMETERS[0]"
|
||||
|
||||
_debug printf \
|
||||
"\${_CMD}: %s\n" \
|
||||
"\${_CMD}: %s\\n" \
|
||||
"${_CMD}"
|
||||
_debug printf \
|
||||
"\${_RAW_OPTIONS} (one per line):\n%s\n" \
|
||||
"\${_RAW_OPTIONS} (one per line):\\n%s\\n" \
|
||||
"${_RAW_OPTIONS}"
|
||||
_debug printf \
|
||||
"\${_COMMAND_ARGV[*]}: %s\n" \
|
||||
"\${_COMMAND_ARGV[*]}: %s\\n" \
|
||||
"${_COMMAND_ARGV[*]}"
|
||||
_debug printf \
|
||||
"\${_COMMAND_PARAMETERS[*]:-}: %s\n" \
|
||||
"\${_COMMAND_PARAMETERS[*]:-}: %s\\n" \
|
||||
"${_COMMAND_PARAMETERS[*]:-}"
|
||||
|
||||
###############################################################################
|
||||
@ -285,7 +285,7 @@ _debug printf \
|
||||
# Set to the program's basename.
|
||||
_ME=$(basename "${0}")
|
||||
|
||||
_debug printf "\${_ME}: %s\n" "${_ME}"
|
||||
_debug printf "\${_ME}: %s\\n" "${_ME}"
|
||||
|
||||
###############################################################################
|
||||
# Load Commands
|
||||
@ -302,8 +302,8 @@ _DEFINED_COMMANDS=()
|
||||
# Loads all of the commands sourced in the environment.
|
||||
_load_commands() {
|
||||
|
||||
_debug printf "_load_commands(): entering...\n"
|
||||
_debug printf "_load_commands() declare -F:\n%s\n" "$(declare -F)"
|
||||
_debug printf "_load_commands(): entering...\\n"
|
||||
_debug printf "_load_commands() declare -F:\\n%s\\n" "$(declare -F)"
|
||||
|
||||
# declare is a bash built-in shell function that, when called with the '-F'
|
||||
# option, displays all of the functions with the format
|
||||
@ -318,7 +318,7 @@ _load_commands() {
|
||||
local function_name
|
||||
function_name=$(printf "%s" "${c}" | awk '{ print $3 }')
|
||||
|
||||
_debug printf "_load_commands() \${function_name}: %s\n" "${function_name}"
|
||||
_debug printf "_load_commands() \${function_name}: %s\\n" "${function_name}"
|
||||
|
||||
# Add the function name to the $_DEFINED_COMMANDS array unless it starts
|
||||
# with an underscore or is one of the desc(), debug(), or die() functions,
|
||||
@ -334,7 +334,7 @@ _load_commands() {
|
||||
done
|
||||
|
||||
_debug printf \
|
||||
"commands() \${_DEFINED_COMMANDS[*]:-}:\n%s\n" \
|
||||
"commands() \${_DEFINED_COMMANDS[*]:-}:\\n%s\\n" \
|
||||
"${_DEFINED_COMMANDS[*]:-}"
|
||||
}
|
||||
|
||||
@ -351,8 +351,8 @@ _load_commands() {
|
||||
#
|
||||
# NOTE: must be called at end of program after all commands have been defined.
|
||||
_main() {
|
||||
_debug printf "main(): entering...\n"
|
||||
_debug printf "main() \${_CMD} (upon entering): %s\n" "${_CMD}"
|
||||
_debug printf "main(): entering...\\n"
|
||||
_debug printf "main() \${_CMD} (upon entering): %s\\n" "${_CMD}"
|
||||
|
||||
# If $_CMD is blank, then set to `$HOSTS_DEFAULT_COMMAND`
|
||||
if [[ -z ${_CMD} ]]
|
||||
@ -416,10 +416,10 @@ _contains() {
|
||||
local test_list=(${*:2})
|
||||
for _test_element in "${test_list[@]:-}"
|
||||
do
|
||||
_debug printf "_contains() \${_test_element}: %s\n" "${_test_element}"
|
||||
_debug printf "_contains() \${_test_element}: %s\\n" "${_test_element}"
|
||||
if [[ "${_test_element}" == "${1}" ]]
|
||||
then
|
||||
_debug printf "_contains() match: %s\n" "${1}"
|
||||
_debug printf "_contains() match: %s\\n" "${1}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
@ -495,7 +495,7 @@ _verify_write_permissions() {
|
||||
else
|
||||
_die printf \
|
||||
"You don't have permission to perform this operation. Try again with:
|
||||
sudo !!\n"
|
||||
sudo !!\\n"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -531,16 +531,16 @@ sudo !!\n"
|
||||
# escaping backslashes, which is more common.
|
||||
desc() {
|
||||
set +e
|
||||
[[ -z ${1} ]] && _die printf "desc: No command name specified.\n"
|
||||
[[ -z ${1} ]] && _die printf "desc: No command name specified.\\n"
|
||||
if [[ -n ${2:-} ]]
|
||||
then
|
||||
read -r -d '' "_desc_${1}" <<HEREDOC
|
||||
${2}
|
||||
HEREDOC
|
||||
_debug printf "desc() set with argument: _desc_%s\n" "${1}"
|
||||
_debug printf "desc() set with argument: _desc_%s\\n" "${1}"
|
||||
else
|
||||
read -r -d '' "_desc_${1}"
|
||||
_debug printf "desc() set with pipe: _desc_%s\n" "${1}"
|
||||
_debug printf "desc() set with pipe: _desc_%s\\n" "${1}"
|
||||
fi
|
||||
set -e
|
||||
}
|
||||
@ -556,9 +556,9 @@ _print_desc() {
|
||||
local var="_desc_${1}"
|
||||
if [[ -n ${!var:-} ]]
|
||||
then
|
||||
printf "%s\n" "${!var}"
|
||||
printf "%s\\n" "${!var}"
|
||||
else
|
||||
printf "No additional information for \`%s\`\n" "${1}"
|
||||
printf "No additional information for \`%s\`\\n" "${1}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -578,7 +578,7 @@ Description:
|
||||
To save you the trouble, the current version is ${_VERSION}
|
||||
HEREDOC
|
||||
version() {
|
||||
printf "%s\n" "${_VERSION}"
|
||||
printf "%s\\n" "${_VERSION}"
|
||||
}
|
||||
|
||||
# Help ########################################################################
|
||||
@ -653,10 +653,10 @@ HEREDOC
|
||||
commands() {
|
||||
if _command_argv_includes "--raw"
|
||||
then
|
||||
printf "%s\n" "${_DEFINED_COMMANDS[@]}"
|
||||
printf "%s\\n" "${_DEFINED_COMMANDS[@]}"
|
||||
else
|
||||
printf "Available commands:\n"
|
||||
printf " %s\n" "${_DEFINED_COMMANDS[@]}"
|
||||
printf "Available commands:\\n"
|
||||
printf " %s\\n" "${_DEFINED_COMMANDS[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -682,7 +682,7 @@ commands() {
|
||||
# - http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
|
||||
# HEREDOC
|
||||
# example() {
|
||||
# printf "Hello, World!\n"
|
||||
# printf "Hello, World!\\n"
|
||||
# }
|
||||
#
|
||||
###############################################################################
|
||||
@ -697,9 +697,9 @@ Description:
|
||||
Add a given IP address and hostname pair, along with an optional comment.
|
||||
HEREDOC
|
||||
add() {
|
||||
_debug printf "add() \${1}: %s\n" "${1:-}"
|
||||
_debug printf "add() \${2}: %s\n" "${2:-}"
|
||||
_debug printf "add() \${3}: %s\n" "${3:-}"
|
||||
_debug printf "add() \${1}: %s\\n" "${1:-}"
|
||||
_debug printf "add() \${2}: %s\\n" "${2:-}"
|
||||
_debug printf "add() \${3}: %s\\n" "${3:-}"
|
||||
|
||||
_verify_write_permissions "$@"
|
||||
local ip=${1:-}
|
||||
@ -711,7 +711,7 @@ add() {
|
||||
exit 1
|
||||
elif [[ -z ${hostname} ]]
|
||||
then
|
||||
printf "Please include a hostname\n"
|
||||
printf "Please include a hostname\\n"
|
||||
${_ME} help add
|
||||
exit 1
|
||||
elif grep \
|
||||
@ -719,26 +719,26 @@ add() {
|
||||
-e "^${ip}\t${hostname}\t.*$" "${HOSTS_PATH}"
|
||||
then
|
||||
_die printf \
|
||||
"Duplicate address/host combination, %s unchanged.\n" \
|
||||
"Duplicate address/host combination, %s unchanged.\\n" \
|
||||
"${HOSTS_PATH}"
|
||||
else
|
||||
if [[ -n ${comment} ]]
|
||||
then
|
||||
local formatted_comment
|
||||
formatted_comment=$(_join " " "${comment[@]}")
|
||||
printf "%s\t%s\t# %s\n" \
|
||||
printf "%s\t%s\t# %s\\n" \
|
||||
"${ip}" \
|
||||
"${hostname}" \
|
||||
"${formatted_comment}" >> "${HOSTS_PATH}"
|
||||
printf "Added:\n%s\t%s\t# %s\n" \
|
||||
printf "Added:\\n%s\t%s\t# %s\\n" \
|
||||
"${ip}" \
|
||||
"${hostname}" \
|
||||
"${formatted_comment}"
|
||||
else
|
||||
printf "%s\t%s\n" \
|
||||
printf "%s\t%s\\n" \
|
||||
"${ip}" \
|
||||
"${hostname}" >> "${HOSTS_PATH}"
|
||||
printf "Added:\n%s\t%s\n" \
|
||||
printf "Added:\\n%s\t%s\\n" \
|
||||
"${ip}" \
|
||||
"${hostname}"
|
||||
fi
|
||||
@ -787,7 +787,7 @@ disable() {
|
||||
${_ME} help disable
|
||||
exit 1
|
||||
else
|
||||
_debug printf "disable() \${search_string}: %s\n" "${search_string}"
|
||||
_debug printf "disable() \${search_string}: %s\\n" "${search_string}"
|
||||
|
||||
target_regex_ip="^\(${search_string}[${_TAB_SPACE_}]..*\)$"
|
||||
target_regex_commented_hostname="^\([^#]..*[${_TAB_SPACE_}]${search_string}[${_TAB_SPACE_}]..*\)$"
|
||||
@ -805,13 +805,13 @@ disable() {
|
||||
-e "s/${target_regex_hostname}/\1/p" \
|
||||
"${HOSTS_PATH}"
|
||||
)
|
||||
_debug printf "disable() \${targets}: %s\n" "${targets}"
|
||||
_debug printf "disable() \${targets}: %s\\n" "${targets}"
|
||||
if [[ -z "${targets}" ]]
|
||||
then
|
||||
_die printf "Not found: %s\n" "${search_string}"
|
||||
_die printf "Not found: %s\\n" "${search_string}"
|
||||
fi
|
||||
|
||||
printf "Disabling:\n%s\n" "${targets}"
|
||||
printf "Disabling:\\n%s\\n" "${targets}"
|
||||
|
||||
# -i '' - in place edit. BSD sed requires extension argument, for GNU
|
||||
# it's optional. More info: http://stackoverflow.com/a/16746032
|
||||
@ -849,7 +849,7 @@ edit() {
|
||||
_verify_write_permissions "$@"
|
||||
if [[ -z "${EDITOR}" ]]
|
||||
then
|
||||
_die printf "\$EDITOR not set.\n"
|
||||
_die printf "\$EDITOR not set.\\n"
|
||||
else
|
||||
"${EDITOR}" "${HOSTS_PATH}"
|
||||
fi
|
||||
@ -873,7 +873,7 @@ enable() {
|
||||
${_ME} help enable
|
||||
exit 1
|
||||
else
|
||||
_debug printf "enable() \${search_string}: %s\n" "${search_string}"
|
||||
_debug printf "enable() \${search_string}: %s\\n" "${search_string}"
|
||||
|
||||
target_regex_ip="^\#disabled: \(${search_string}[${_TAB_SPACE_}]..*\)$"
|
||||
target_regex_commented_hostname="^\#disabled: \(..*[${_TAB_SPACE_}]${search_string}[${_TAB_SPACE_}]..*\)$"
|
||||
@ -891,13 +891,13 @@ enable() {
|
||||
-e "s/${target_regex_hostname}/\1/p" \
|
||||
"${HOSTS_PATH}"
|
||||
)
|
||||
_debug printf "enable() \${targets}: %s\n" "${targets}"
|
||||
_debug printf "enable() \${targets}: %s\\n" "${targets}"
|
||||
if [[ -z "${targets}" ]]
|
||||
then
|
||||
_die printf "Not found: %s\n" "${search_string}"
|
||||
_die printf "Not found: %s\\n" "${search_string}"
|
||||
fi
|
||||
|
||||
printf "Enabling:\n%s\n" "${targets}"
|
||||
printf "Enabling:\\n%s\\n" "${targets}"
|
||||
|
||||
# -i '' - in place edit. BSD sed requires extension argument, for GNU
|
||||
# it's optional. More info: http://stackoverflow.com/a/16746032
|
||||
@ -957,7 +957,7 @@ list() {
|
||||
then
|
||||
if [[ "${1}" == "disabled" ]]
|
||||
then
|
||||
printf "%s\n" "${disabled_records}"
|
||||
printf "%s\\n" "${disabled_records}"
|
||||
elif [[ "${1}" == "enabled" ]]
|
||||
then
|
||||
grep -v -e '^$' -e '^\s*\#' "${HOSTS_PATH}"
|
||||
@ -970,7 +970,7 @@ list() {
|
||||
grep -v -e '^$' -e '^\s*\#' "${HOSTS_PATH}"
|
||||
if [[ -n "${disabled_records}" ]]
|
||||
then
|
||||
printf "\nDisabled:\n%s\n" "${disabled_records}"
|
||||
printf "\\nDisabled:\\n%s\\n" "${disabled_records}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -999,8 +999,8 @@ remove() {
|
||||
local search_hostname=""
|
||||
local search_string=""
|
||||
|
||||
_debug printf "remove() \${1}: %s\n" "${1:-}"
|
||||
_debug printf "remove() \${2}: %s\n" "${2:-}"
|
||||
_debug printf "remove() \${1}: %s\\n" "${1:-}"
|
||||
_debug printf "remove() \${2}: %s\\n" "${2:-}"
|
||||
|
||||
for arg in "${_COMMAND_ARGV[@]:-}"
|
||||
do
|
||||
@ -1014,9 +1014,9 @@ remove() {
|
||||
esac
|
||||
done
|
||||
|
||||
_debug printf "remove() \${arguments[0]}: %s\n" "${arguments[0]:-}"
|
||||
_debug printf "remove() \${arguments[1]}: %s\n" "${arguments[1]:-}"
|
||||
_debug printf "remove() \${arguments[2]}: %s\n" "${arguments[2]:-}"
|
||||
_debug printf "remove() \${arguments[0]}: %s\\n" "${arguments[0]:-}"
|
||||
_debug printf "remove() \${arguments[1]}: %s\\n" "${arguments[1]:-}"
|
||||
_debug printf "remove() \${arguments[2]}: %s\\n" "${arguments[2]:-}"
|
||||
|
||||
if [[ -z "${arguments[1]:-}" ]]
|
||||
then
|
||||
@ -1027,10 +1027,10 @@ remove() {
|
||||
search_ip="${arguments[1]}"
|
||||
search_hostname="${arguments[2]}"
|
||||
is_search_pair=1
|
||||
_debug printf "remove() \${is_search_pair}: %s\n" "${is_search_pair}"
|
||||
_debug printf "remove() \${is_search_pair}: %s\\n" "${is_search_pair}"
|
||||
else
|
||||
search_string="${arguments[1]:-}"
|
||||
_debug printf "remove() \${search_string}: %s\n" "${search_string}"
|
||||
_debug printf "remove() \${search_string}: %s\\n" "${search_string}"
|
||||
fi
|
||||
|
||||
# Regular Expression Notes
|
||||
@ -1068,13 +1068,13 @@ remove() {
|
||||
|
||||
if [[ -z ${target_records:-} ]]
|
||||
then
|
||||
printf "No matching records found.\n"
|
||||
printf "No matching records found.\\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! ((force_skip_prompt))
|
||||
then
|
||||
printf "Removing the following records:\n%s\n" "${target_records}"
|
||||
printf "Removing the following records:\\n%s\\n" "${target_records}"
|
||||
while true
|
||||
do
|
||||
read -r -p "Are you sure you want to proceed? [y/N] " yn
|
||||
@ -1083,7 +1083,7 @@ remove() {
|
||||
break
|
||||
;;
|
||||
* )
|
||||
printf "Exiting...\n"
|
||||
printf "Exiting...\\n"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
@ -1107,7 +1107,7 @@ remove() {
|
||||
-e "/${target_regex_hostname}/d" \
|
||||
"${HOSTS_PATH}"
|
||||
fi
|
||||
printf "Removed:\n%s\n" "${target_records}"
|
||||
printf "Removed:\\n%s\\n" "${target_records}"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------- search
|
||||
@ -1152,11 +1152,11 @@ show() {
|
||||
# Output disabled records secondly for better organization.
|
||||
if [[ -n "${enabled_records}" ]]
|
||||
then
|
||||
printf "%s\n" "${enabled_records}"
|
||||
printf "%s\\n" "${enabled_records}"
|
||||
fi
|
||||
if [[ -n "${disabled_records}" ]]
|
||||
then
|
||||
printf "%s\n" "${disabled_records}"
|
||||
printf "%s\\n" "${disabled_records}"
|
||||
fi
|
||||
else
|
||||
${_ME} help show
|
||||
|
@ -6,8 +6,8 @@ load test_helper
|
||||
|
||||
@test "\`add\` with no arguments exits with status 1." {
|
||||
run "${_HOSTS}" add
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@ -15,15 +15,15 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" add
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "$(cat "${HOSTS_PATH}")" == "${_original}" ]]
|
||||
}
|
||||
|
||||
@test "\`add\` with no arguments prints help information." {
|
||||
run "${_HOSTS}" add
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts add <ip> <hostname> [<comment>]" ]]
|
||||
}
|
||||
@ -32,8 +32,8 @@ load test_helper
|
||||
|
||||
@test "\`add <ip>\` exits with status 1." {
|
||||
run "${_HOSTS}" add 0.0.0.0
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@ -41,15 +41,15 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" add 0.0.0.0
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "$(cat "${HOSTS_PATH}")" == "${_original}" ]]
|
||||
}
|
||||
|
||||
@test "\`add <ip>\` prints help information." {
|
||||
run "${_HOSTS}" add 0.0.0.0
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Please include a hostname" ]]
|
||||
[[ "${lines[1]}" == "Usage:" ]]
|
||||
[[ "${lines[2]}" == " hosts add <ip> <hostname> [<comment>]" ]]
|
||||
@ -59,8 +59,8 @@ load test_helper
|
||||
|
||||
@test "\`add <ip> <hostname>\` exits with status 0." {
|
||||
run "${_HOSTS}" add 0.0.0.0 example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" add 0.0.0.0 example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
_compare '0.0.0.0 example.com' "$(sed -n '11p' "${HOSTS_PATH}")"
|
||||
[[ "$(cat "${HOSTS_PATH}")" != "${_original}" ]]
|
||||
@ -78,8 +78,8 @@ load test_helper
|
||||
|
||||
@test "\`add <ip> <hostname>\` prints feedback." {
|
||||
run "${_HOSTS}" add 0.0.0.0 example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Added:" ]]
|
||||
[[ "${lines[1]}" == "0.0.0.0 example.com" ]]
|
||||
}
|
||||
@ -88,8 +88,8 @@ load test_helper
|
||||
|
||||
@test "\`add <ip> <hostname> [comment]\` exits with status 0." {
|
||||
run "${_HOSTS}" add 0.0.0.0 example.com 'Comment.'
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -97,16 +97,16 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" add 0.0.0.0 example.com 'Comment.'
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "$(cat "${HOSTS_PATH}")" != "${_original}" ]]
|
||||
[[ "$(sed -n '11p' "${HOSTS_PATH}")" == "0.0.0.0 example.com # Comment." ]]
|
||||
}
|
||||
|
||||
@test "\`add <ip> <hostname> [comment]\` prints feedback." {
|
||||
run "${_HOSTS}" add 0.0.0.0 example.com 'Comment.'
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Added:" ]]
|
||||
[[ "${lines[1]}" == "0.0.0.0 example.com # Comment." ]]
|
||||
}
|
||||
@ -120,8 +120,8 @@ load test_helper
|
||||
|
||||
@test "\`help add\` prints help information." {
|
||||
run "${_HOSTS}" help add
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts add <ip> <hostname> [<comment>]" ]]
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ load test_helper
|
||||
|
||||
@test "\`block\` with no arguments exits with status 1." {
|
||||
run "${_HOSTS}" block
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@ -15,15 +15,15 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" block
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "$(cat "${HOSTS_PATH}")" == "${_original}" ]]
|
||||
}
|
||||
|
||||
@test "\`block\` with no arguments prints help information." {
|
||||
run "${_HOSTS}" block
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts block <hostname>" ]]
|
||||
}
|
||||
@ -32,8 +32,8 @@ load test_helper
|
||||
|
||||
@test "\`block <hostname>\` exits with status 0." {
|
||||
run "${_HOSTS}" block example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -41,8 +41,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" block example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
_compare '127.0.0.1 example.com' "$(sed -n '11p' "${HOSTS_PATH}")"
|
||||
[[ "$(cat "${HOSTS_PATH}")" != "${_original}" ]]
|
||||
@ -51,8 +51,8 @@ load test_helper
|
||||
|
||||
@test "\`block <hostname>\` prints feedback." {
|
||||
run "${_HOSTS}" block example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Added:" ]]
|
||||
[[ "${lines[1]}" == "127.0.0.1 example.com" ]]
|
||||
[[ "${lines[2]}" == "Added:" ]]
|
||||
@ -70,8 +70,8 @@ load test_helper
|
||||
|
||||
@test "\`help block\` prints help information." {
|
||||
run "${_HOSTS}" help block
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts block <hostname>" ]]
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ load test_helper
|
||||
|
||||
@test "\`disable\` with no arguments exits with status 1." {
|
||||
run "${_HOSTS}" disable
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@ -15,15 +15,15 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" disable
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "$(cat "${HOSTS_PATH}")" == "${_original}" ]]
|
||||
}
|
||||
|
||||
@test "\`disable\` with no arguments prints help information." {
|
||||
run "${_HOSTS}" disable
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts disable (<ip> | <hostname> | <search string>)" ]]
|
||||
}
|
||||
@ -37,8 +37,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" disable 0.0.0.0
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -50,8 +50,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" disable 0.0.0.0
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
[[ "$(sed -n '11p' "${HOSTS_PATH}")" == "#disabled: 0.0.0.0 example.com" ]]
|
||||
[[ "$(sed -n '12p' "${HOSTS_PATH}")" == "127.0.0.1 example.net" ]]
|
||||
@ -65,8 +65,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" disable 0.0.0.0
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
[[ "$(sed -n '11p' "${HOSTS_PATH}")" == "#disabled: 0.0.0.0 example.com" ]]
|
||||
[[ "$(sed -n '12p' "${HOSTS_PATH}")" == "#disabled: 0.0.0.0 example.net" ]]
|
||||
@ -79,8 +79,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" disable 0.0.0.0
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Disabling:" ]]
|
||||
[[ "${lines[1]}" == "0.0.0.0 example.com" ]]
|
||||
}
|
||||
@ -94,8 +94,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" disable example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -107,8 +107,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" disable example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
[[ "$(sed -n '11p' "${HOSTS_PATH}")" == "#disabled: 0.0.0.0 example.com" ]]
|
||||
[[ "$(sed -n '12p' "${HOSTS_PATH}")" == "127.0.0.1 example.net" ]]
|
||||
@ -122,8 +122,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" disable example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
[[ "$(sed -n '11p' "${HOSTS_PATH}")" == "#disabled: 0.0.0.0 example.com" ]]
|
||||
[[ "$(sed -n '12p' "${HOSTS_PATH}")" == "#disabled: 127.0.0.1 example.com" ]]
|
||||
@ -136,8 +136,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" disable example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Disabling:" ]]
|
||||
[[ "${lines[1]}" == "0.0.0.0 example.com" ]]
|
||||
}
|
||||
@ -151,8 +151,8 @@ load test_helper
|
||||
|
||||
@test "\`help disable\` prints help information." {
|
||||
run "${_HOSTS}" help disable
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts disable (<ip> | <hostname> | <search string>)" ]]
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" disabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" disabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "0.0.0.0 example.com" ]]
|
||||
[[ "${lines[1]}" == "127.0.0.1 example.com" ]]
|
||||
[[ "${lines[2]}" == "" ]]
|
||||
@ -43,8 +43,8 @@ load test_helper
|
||||
|
||||
@test "\`help disabled\` prints help information." {
|
||||
run "${_HOSTS}" help disabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts disabled" ]]
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ load test_helper
|
||||
|
||||
@test "\`enable\` with no arguments exits with status 1." {
|
||||
run "${_HOSTS}" enable
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@ -15,15 +15,15 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" enable
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "$(cat "${HOSTS_PATH}")" == "${_original}" ]]
|
||||
}
|
||||
|
||||
@test "\`enable\` with no arguments prints help information." {
|
||||
run "${_HOSTS}" enable
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts enable (<ip> | <hostname> | <search string>)" ]]
|
||||
}
|
||||
@ -39,8 +39,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" enable 127.0.0.2
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -55,8 +55,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" enable 127.0.0.2
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
[[ "$(sed -n '11p' "${HOSTS_PATH}")" == "#disabled: 0.0.0.0 example.com" ]]
|
||||
[[ "$(sed -n '12p' "${HOSTS_PATH}")" == "#disabled: 0.0.0.0 example.net" ]]
|
||||
@ -74,8 +74,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" enable 0.0.0.0
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare \
|
||||
"${_original}" \
|
||||
"$(cat "${HOSTS_PATH}")"
|
||||
@ -103,8 +103,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" enable 127.0.0.2
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Enabling:" ]]
|
||||
[[ "${lines[1]}" == "127.0.0.2 example.com" ]]
|
||||
}
|
||||
@ -120,8 +120,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" enable example.net
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -135,8 +135,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" enable example.net
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
[[ "$(sed -n '11p' "${HOSTS_PATH}")" == "#disabled: 0.0.0.0 example.com" ]]
|
||||
[[ "$(sed -n '12p' "${HOSTS_PATH}")" == "0.0.0.0 example.net" ]]
|
||||
@ -154,8 +154,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" enable example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare \
|
||||
"${_original}" \
|
||||
"$(cat "${HOSTS_PATH}")"
|
||||
@ -183,8 +183,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" enable example.net
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Enabling:" ]]
|
||||
[[ "${lines[1]}" == "0.0.0.0 example.net" ]]
|
||||
}
|
||||
@ -198,8 +198,8 @@ load test_helper
|
||||
|
||||
@test "\`help enable\` prints help information." {
|
||||
run "${_HOSTS}" help enable
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts enable (<ip> | <hostname> | <search string>)" ]]
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" enabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" enabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "127.0.0.1 localhost" ]]
|
||||
[[ "${lines[1]}" == "255.255.255.255 broadcasthost" ]]
|
||||
[[ "${lines[2]}" == "::1 localhost" ]]
|
||||
@ -45,8 +45,8 @@ load test_helper
|
||||
|
||||
@test "\`help enabled\` prints help information." {
|
||||
run "${_HOSTS}" help enabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts enabled" ]]
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ load test_helper
|
||||
|
||||
@test "\`help file\` prints help information." {
|
||||
run "${_HOSTS}" help file
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts file" ]]
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" list
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" list
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_expected="\
|
||||
127.0.0.1 localhost
|
||||
255.255.255.255 broadcasthost
|
||||
@ -54,8 +54,8 @@ Disabled:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" list enabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ Disabled:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" list enabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "127.0.0.1 localhost" ]]
|
||||
[[ "${lines[1]}" == "255.255.255.255 broadcasthost" ]]
|
||||
[[ "${lines[2]}" == "::1 localhost" ]]
|
||||
@ -88,8 +88,8 @@ Disabled:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" list disabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -102,8 +102,8 @@ Disabled:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" list disabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "0.0.0.0 example.com" ]]
|
||||
[[ "${lines[1]}" == "127.0.0.1 example.com" ]]
|
||||
[[ "${lines[2]}" == "" ]]
|
||||
@ -119,8 +119,8 @@ Disabled:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" list example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -132,8 +132,8 @@ Disabled:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" list example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "0.0.0.0 example.com" ]]
|
||||
[[ "${lines[1]}" == "127.0.0.1 example.com" ]]
|
||||
[[ "${lines[2]}" == "" ]]
|
||||
@ -148,8 +148,8 @@ Disabled:
|
||||
|
||||
@test "\`help list\` prints help information." {
|
||||
run "${_HOSTS}" help list
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts list [enabled | disabled | <search string>]" ]]
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ load test_helper
|
||||
|
||||
@test "\`remove\` with no arguments exits with status 1." {
|
||||
run "${_HOSTS}" remove
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@ -15,15 +15,15 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" remove
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "$(cat "${HOSTS_PATH}")" == "${_original}" ]]
|
||||
}
|
||||
|
||||
@test "\`remove\` with no arguments prints help information." {
|
||||
run "${_HOSTS}" remove
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts remove (<ip> | <hostname> | <search string>) [--force]" ]]
|
||||
}
|
||||
@ -38,8 +38,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" remove 127.0.0.3 --force
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@ -51,8 +51,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" remove 127.0.0.3 --force
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${output} == "No matching records found." ]]
|
||||
}
|
||||
|
||||
@ -66,8 +66,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" remove 127.0.0.2 --force
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -80,8 +80,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" remove 127.0.0.2 --force
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
[[ "$(sed -n '11p' "${HOSTS_PATH}")" == "0.0.0.0 example.com" ]]
|
||||
[[ "$(sed -n '12p' "${HOSTS_PATH}")" == "0.0.0.0 example.net" ]]
|
||||
@ -99,8 +99,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" remove 0.0.0.0 --force
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_expected="\
|
||||
##
|
||||
# Host Database
|
||||
@ -126,8 +126,8 @@ fe80::1%lo0 localhost
|
||||
}
|
||||
|
||||
run "${_HOSTS}" remove 127.0.0.2 --force
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Removed:" ]]
|
||||
[[ "${lines[1]}" == "127.0.0.2 example.com" ]]
|
||||
}
|
||||
@ -142,8 +142,8 @@ fe80::1%lo0 localhost
|
||||
}
|
||||
|
||||
run "${_HOSTS}" remove example.com --force
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -156,8 +156,8 @@ fe80::1%lo0 localhost
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" remove example.com --force
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
[[ "$(sed -n '11p' "${HOSTS_PATH}")" == "0.0.0.0 example.net" ]]
|
||||
[[ "$(sed -n '12p' "${HOSTS_PATH}")" == "" ]]
|
||||
@ -174,8 +174,8 @@ fe80::1%lo0 localhost
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" remove example.com --force
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_expected="\
|
||||
##
|
||||
# Host Database
|
||||
@ -202,8 +202,8 @@ fe80::1%lo0 localhost
|
||||
}
|
||||
|
||||
run "${_HOSTS}" remove example.com --force
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_expected="\
|
||||
Removed:
|
||||
0.0.0.0 example.com
|
||||
@ -220,8 +220,8 @@ Removed:
|
||||
|
||||
@test "\`help remove\` prints help information." {
|
||||
run "${_HOSTS}" help remove
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts remove (<ip> | <hostname> | <search string>) [--force]" ]]
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" search
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" search
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_expected="\
|
||||
Usage:
|
||||
hosts search <search string>
|
||||
@ -50,8 +50,8 @@ Description:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" search enabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -64,8 +64,8 @@ Description:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" search enabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "127.0.0.1 localhost" ]]
|
||||
[[ "${lines[1]}" == "255.255.255.255 broadcasthost" ]]
|
||||
[[ "${lines[2]}" == "::1 localhost" ]]
|
||||
@ -84,8 +84,8 @@ Description:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" search disabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -98,8 +98,8 @@ Description:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" search disabled
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "0.0.0.0 example.com" ]]
|
||||
[[ "${lines[1]}" == "127.0.0.1 example.com" ]]
|
||||
[[ "${lines[2]}" == "" ]]
|
||||
@ -115,8 +115,8 @@ Description:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" search example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -128,8 +128,8 @@ Description:
|
||||
}
|
||||
|
||||
run "${_HOSTS}" search example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "0.0.0.0 example.com" ]]
|
||||
[[ "${lines[1]}" == "127.0.0.1 example.com" ]]
|
||||
[[ "${lines[2]}" == "" ]]
|
||||
@ -144,8 +144,8 @@ Description:
|
||||
|
||||
@test "\`help search\` prints help information." {
|
||||
run "${_HOSTS}" help search
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts search <search string>" ]]
|
||||
}
|
||||
|
@ -6,15 +6,15 @@ load test_helper
|
||||
|
||||
@test "\`show\` with no arguments exits with status 1." {
|
||||
run "${_HOSTS}" show
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@test "\`show\` with no arguments prints help information." {
|
||||
run "${_HOSTS}" show
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts show (<ip> | <hostname> | <search string>)" ]]
|
||||
}
|
||||
@ -30,8 +30,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" show 0.0.0.0
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -44,8 +44,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" show 0.0.0.0
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
|
||||
[[ "${lines[0]}" == "0.0.0.0 example.net" ]]
|
||||
[[ "${lines[1]}" == "disabled: 0.0.0.0 example.com" ]]
|
||||
@ -62,8 +62,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" show example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -76,8 +76,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" show example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
|
||||
[[ "${lines[0]}" == "127.0.0.2 example.com" ]]
|
||||
[[ "${lines[1]}" == "disabled: 0.0.0.0 example.com" ]]
|
||||
@ -92,8 +92,8 @@ load test_helper
|
||||
|
||||
@test "\`help show\` prints help information." {
|
||||
run "${_HOSTS}" help show
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts show (<ip> | <hostname> | <search string>)" ]]
|
||||
}
|
||||
|
@ -40,6 +40,6 @@ teardown() {
|
||||
_compare() {
|
||||
local _expected="${1:-}"
|
||||
local _actual="${2:-}"
|
||||
printf "expected:\n%s\n" "${_expected}"
|
||||
printf "actual:\n%s\n" "${_actual}"
|
||||
printf "expected:\\n%s\\n" "${_expected}"
|
||||
printf "actual:\\n%s\\n" "${_actual}"
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ load test_helper
|
||||
|
||||
@test "\`unblock\` with no arguments exits with status 1." {
|
||||
run "${_HOSTS}" unblock
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@ -15,15 +15,15 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" unblock
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "$(cat "${HOSTS_PATH}")" == "${_original}" ]]
|
||||
}
|
||||
|
||||
@test "\`unblock\` with no arguments prints help information." {
|
||||
run "${_HOSTS}" unblock
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts unblock <hostname>" ]]
|
||||
}
|
||||
@ -36,8 +36,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" unblock example.net
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 1 ]]
|
||||
}
|
||||
|
||||
@ -47,8 +47,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" unblock example.net
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${output} == "No matching records found." ]]
|
||||
}
|
||||
|
||||
@ -62,8 +62,8 @@ load test_helper
|
||||
}
|
||||
|
||||
run "${_HOSTS}" unblock example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
|
||||
@ -76,8 +76,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" unblock example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_compare "${_original}" "$(cat "${HOSTS_PATH}")"
|
||||
[[ "$(sed -n '11p' "${HOSTS_PATH}")" == "0.0.0.0 example.com" ]]
|
||||
[[ "$(sed -n '12p' "${HOSTS_PATH}")" == "127.0.0.1 example.net" ]]
|
||||
@ -93,8 +93,8 @@ load test_helper
|
||||
_original="$(cat "${HOSTS_PATH}")"
|
||||
|
||||
run "${_HOSTS}" unblock example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_expected="\
|
||||
##
|
||||
# Host Database
|
||||
@ -121,8 +121,8 @@ fe80::1%lo0 localhost
|
||||
}
|
||||
|
||||
run "${_HOSTS}" unblock example.com
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
_expected="\
|
||||
Removed:
|
||||
127.0.0.1 example.com
|
||||
@ -142,8 +142,8 @@ Removed:
|
||||
|
||||
@test "\`help unblock\` prints help information." {
|
||||
run "${_HOSTS}" help unblock
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts unblock <hostname>" ]]
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ load test_helper
|
||||
|
||||
@test "\`help version\` prints help information." {
|
||||
run "${_HOSTS}" help version
|
||||
printf "\${status}: %s\n" "${status}"
|
||||
printf "\${output}: '%s'\n" "${output}"
|
||||
printf "\${status}: %s\\n" "${status}"
|
||||
printf "\${output}: '%s'\\n" "${output}"
|
||||
[[ "${lines[0]}" == "Usage:" ]]
|
||||
[[ "${lines[1]}" == " hosts (version | --version)" ]]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user