1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-05-30 05:00:48 +00:00

Replace 'domain' with 'hostname' in regular expression variable names.

'hostname' is more accurate and consistent for this context.
This commit is contained in:
William Melody 2015-09-12 16:14:36 -07:00
parent 95fd43668a
commit 1242d0b4bc

24
hosts
View File

@ -732,8 +732,8 @@ disable() {
_debug printf "disable() \$search_term: %s\n" "$search_term" _debug printf "disable() \$search_term: %s\n" "$search_term"
target_regex_ip="^\(${search_term}[${_TAB_SPACE_}]..*\)$" target_regex_ip="^\(${search_term}[${_TAB_SPACE_}]..*\)$"
target_regex_commented_domain="^\([^#]..*[${_TAB_SPACE_}]${search_term}[${_TAB_SPACE_}]..*\)$" target_regex_commented_hostname="^\([^#]..*[${_TAB_SPACE_}]${search_term}[${_TAB_SPACE_}]..*\)$"
target_regex_domain="^\([^#]..*[${_TAB_SPACE_}]${search_term}\)$" target_regex_hostname="^\([^#]..*[${_TAB_SPACE_}]${search_term}\)$"
# Regular Expression Notes # Regular Expression Notes
# #
@ -743,8 +743,8 @@ disable() {
targets=$( targets=$(
sed -n \ sed -n \
-e "s/${target_regex_ip}/\1/p" \ -e "s/${target_regex_ip}/\1/p" \
-e "s/${target_regex_commented_domain}/\1/p" \ -e "s/${target_regex_commented_hostname}/\1/p" \
-e "s/${target_regex_domain}/\1/p" \ -e "s/${target_regex_hostname}/\1/p" \
"${HOSTS_PATH}" "${HOSTS_PATH}"
) )
_debug printf "disable() \$targets: %s\n" "$targets" _debug printf "disable() \$targets: %s\n" "$targets"
@ -759,8 +759,8 @@ disable() {
# it's optional. More info: http://stackoverflow.com/a/16746032 # it's optional. More info: http://stackoverflow.com/a/16746032
sed -i '' \ sed -i '' \
-e "s/${target_regex_ip}/\#disabled: \1/g" \ -e "s/${target_regex_ip}/\#disabled: \1/g" \
-e "s/${target_regex_commented_domain}/\#disabled: \1/g" \ -e "s/${target_regex_commented_hostname}/\#disabled: \1/g" \
-e "s/${target_regex_domain}/\#disabled: \1/g" \ -e "s/${target_regex_hostname}/\#disabled: \1/g" \
"${HOSTS_PATH}" "${HOSTS_PATH}"
fi fi
} }
@ -818,8 +818,8 @@ enable() {
_debug printf "enable() \$search_term: %s\n" "$search_term" _debug printf "enable() \$search_term: %s\n" "$search_term"
target_regex_ip="^\#disabled: \(${search_term}[${_TAB_SPACE_}]..*\)$" target_regex_ip="^\#disabled: \(${search_term}[${_TAB_SPACE_}]..*\)$"
target_regex_commented_domain="^\#disabled: \(..*[${_TAB_SPACE_}]${search_term}[${_TAB_SPACE_}]..*\)$" target_regex_commented_hostname="^\#disabled: \(..*[${_TAB_SPACE_}]${search_term}[${_TAB_SPACE_}]..*\)$"
target_regex_domain="^\#disabled: \(..*[${_TAB_SPACE_}]${search_term}\)$" target_regex_hostname="^\#disabled: \(..*[${_TAB_SPACE_}]${search_term}\)$"
# Regular Expression Notes # Regular Expression Notes
# #
@ -829,8 +829,8 @@ enable() {
targets=$( targets=$(
sed -n \ sed -n \
-e "s/${target_regex_ip}/\1/p" \ -e "s/${target_regex_ip}/\1/p" \
-e "s/${target_regex_commented_domain}/\1/p" \ -e "s/${target_regex_commented_hostname}/\1/p" \
-e "s/${target_regex_domain}/\1/p" \ -e "s/${target_regex_hostname}/\1/p" \
"${HOSTS_PATH}" "${HOSTS_PATH}"
) )
_debug printf "enable() \$targets: %s\n" "$targets" _debug printf "enable() \$targets: %s\n" "$targets"
@ -845,8 +845,8 @@ enable() {
# it's optional. More info: http://stackoverflow.com/a/16746032 # it's optional. More info: http://stackoverflow.com/a/16746032
sed -i '' \ sed -i '' \
-e "s/${target_regex_ip}/\1/g" \ -e "s/${target_regex_ip}/\1/g" \
-e "s/${target_regex_commented_domain}/\1/g" \ -e "s/${target_regex_commented_hostname}/\1/g" \
-e "s/${target_regex_domain}/\1/g" \ -e "s/${target_regex_hostname}/\1/g" \
"${HOSTS_PATH}" "${HOSTS_PATH}"
fi fi
} }