Rename `SED_COMMAND` variable to `_SED_I_COMMAND`.

This commit is contained in:
William Melody 2020-03-16 20:46:34 -07:00
parent 0a39dfe693
commit 0f3c59bd86
1 changed files with 8 additions and 8 deletions

16
hosts
View File

@ -57,20 +57,20 @@ export _SPACE_=$' '
export _TAB_SPACE_="${_TAB_}${_SPACE_}"
export _TAB_SPACE_CC_="[${_TAB_SPACE_}]"
# $SED_COMMAND
# $_SED_I_COMMAND
#
# `sed -i` takes an extension on macOS, but that extension can cause errors in
# GNU `sed`.
#
# NOTE: To use this command, call it with `"${SED_COMMAND[@]}"`
# NOTE: To use this command, call it with `"${_SED_I_COMMAND[@]}"`
#
# https://stackoverflow.com/q/43171648
# http://stackoverflow.com/a/16746032
if sed --help >/dev/null 2>&1
then # GNU
export SED_COMMAND=(sed -i)
export _SED_I_COMMAND=(sed -i)
else # macOS
export SED_COMMAND=(sed -i '')
export _SED_I_COMMAND=(sed -i '')
fi
###############################################################################
@ -972,7 +972,7 @@ disable() {
printf "Disabling:\\n%s\\n" "${_targets}"
"${SED_COMMAND[@]}" \
"${_SED_I_COMMAND[@]}" \
-e "s/${_regex_ip}/\\#disabled: \\1/g" \
-e "s/${_regex_commented_hostname}/\\#disabled: \\1/g" \
-e "s/${_regex_hostname}/\\#disabled: \\1/g" \
@ -1066,7 +1066,7 @@ enable() {
printf "Enabling:\\n%s\\n" "${_targets}"
"${SED_COMMAND[@]}" \
"${_SED_I_COMMAND[@]}" \
-e "s/${_regex_ip}/\\1/g" \
-e "s/${_regex_commented_hostname}/\\1/g" \
-e "s/${_regex_hostname}/\\1/g" \
@ -1272,12 +1272,12 @@ remove() {
if ((_is_search_pair))
then
"${SED_COMMAND[@]}" \
"${_SED_I_COMMAND[@]}" \
-e "/${_regex_ip_hostname_commented}/d" \
-e "/${_regex_ip_hostname}/d" \
"${HOSTS_PATH}"
else
"${SED_COMMAND[@]}" \
"${_SED_I_COMMAND[@]}" \
-e "/${_regex_ip}/d" \
-e "/${_regex_commented_hostname}/d" \
-e "/${_regex_hostname}/d" \