Fix incorrect variable usage

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
Mcat12 2018-07-08 15:38:44 -04:00
parent c5bb404d6a
commit cfd95dbe87
No known key found for this signature in database
GPG key ID: ABB8FC9789AF524D

View file

@ -136,6 +136,7 @@ AddDomain() {
elif [[ "${list}" == "${regexlist}" ]]; then elif [[ "${list}" == "${regexlist}" ]]; then
[[ -z "${type}" ]] && type="--wildcard-only" [[ -z "${type}" ]] && type="--wildcard-only"
bool=true bool=true
domain="${1}"
[[ "${wildcard}" == true ]] && domain="((^)|(\\.))${domain}$" [[ "${wildcard}" == true ]] && domain="((^)|(\\.))${domain}$"
@ -145,13 +146,13 @@ AddDomain() {
if [[ "${bool}" == false ]]; then if [[ "${bool}" == false ]]; then
if [[ "${verbose}" == true ]]; then if [[ "${verbose}" == true ]]; then
echo -e " ${INFO} Adding ${1} to regex list..." echo -e " ${INFO} Adding ${domain} to regex list..."
fi fi
reload="restart" reload="restart"
echo "$1" >> "${regexlist}" echo "$domain" >> "${regexlist}"
else else
if [[ "${verbose}" == true ]]; then if [[ "${verbose}" == true ]]; then
echo -e " ${INFO} ${1} already exists in regex list, no need to add!" echo -e " ${INFO} ${domain} already exists in regex list, no need to add!"
fi fi
fi fi
fi fi
@ -183,6 +184,8 @@ RemoveDomain() {
fi fi
elif [[ "${list}" == "${regexlist}" ]]; then elif [[ "${list}" == "${regexlist}" ]]; then
[[ -z "${type}" ]] && type="--wildcard-only" [[ -z "${type}" ]] && type="--wildcard-only"
domain="${1}"
[[ "${wildcard}" == true ]] && domain="((^)|(\\.))${domain}$" [[ "${wildcard}" == true ]] && domain="((^)|(\\.))${domain}$"
bool=true bool=true
@ -190,14 +193,14 @@ RemoveDomain() {
grep -Fx "${domain}" "${regexlist}" > /dev/null 2>&1 || bool=false grep -Fx "${domain}" "${regexlist}" > /dev/null 2>&1 || bool=false
if [[ "${bool}" == true ]]; then if [[ "${bool}" == true ]]; then
# Remove it from the other one # Remove it from the other one
echo -e " ${INFO} Removing $1 from regex list..." echo -e " ${INFO} Removing $domain from regex list..."
local lineNumber local lineNumber
lineNumber=$(grep -Fnx "$1" "${list}" | cut -f1 -d:) lineNumber=$(grep -Fnx "$domain" "${list}" | cut -f1 -d:)
sed -i "${lineNumber}d" "${list}" sed -i "${lineNumber}d" "${list}"
reload=true reload=true
else else
if [[ "${verbose}" == true ]]; then if [[ "${verbose}" == true ]]; then
echo -e " ${INFO} ${1} does not exist in regex list, no need to remove!" echo -e " ${INFO} ${domain} does not exist in regex list, no need to remove!"
fi fi
fi fi
fi fi