mirror of
https://github.com/hectorm/hblock.git
synced 2026-04-18 21:16:32 +05:30
Removed double dash from "printf".
It's not necessary and the Toybox implementation interprets it literally.
This commit is contained in:
parent
16227fd211
commit
e34217ee24
26 changed files with 108 additions and 108 deletions
48
hblock
48
hblock
|
|
@ -136,13 +136,13 @@ optArgBool() {
|
||||||
else optArg='false'; fi
|
else optArg='false'; fi
|
||||||
}
|
}
|
||||||
optDie() {
|
optDie() {
|
||||||
printf -- '%s\n' "${@-}" "Try 'hblock --help' for more information" >&2
|
printf '%s\n' "${@-}" "Try 'hblock --help' for more information" >&2
|
||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
# Show help and quit.
|
# Show help and quit.
|
||||||
showHelp() {
|
showHelp() {
|
||||||
printf -- '%s\n' "$(sed -e 's/%NL/\n/g' <<-EOF
|
printf '%s\n' "$(sed -e 's/%NL/\n/g' <<-EOF
|
||||||
Usage: hblock [OPTION]...
|
Usage: hblock [OPTION]...
|
||||||
|
|
||||||
hBlock is a POSIX-compliant shell script that gets a list of domains that serve
|
hBlock is a POSIX-compliant shell script that gets a list of domains that serve
|
||||||
|
|
@ -248,7 +248,7 @@ showHelp() {
|
||||||
# Show version number and quit.
|
# Show version number and quit.
|
||||||
showVersion() {
|
showVersion() {
|
||||||
getMetadata() { sed -ne 's|^# '"${1:?}"':[[:blank:]]*\(.\{1,\}\)$|\1|p' -- "${0:?}"; }
|
getMetadata() { sed -ne 's|^# '"${1:?}"':[[:blank:]]*\(.\{1,\}\)$|\1|p' -- "${0:?}"; }
|
||||||
printf -- '%s\n' "$(cat <<-EOF
|
printf '%s\n' "$(cat <<-EOF
|
||||||
hBlock $(getMetadata 'Version')
|
hBlock $(getMetadata 'Version')
|
||||||
Author: $(getMetadata 'Author')
|
Author: $(getMetadata 'Author')
|
||||||
License: $(getMetadata 'License')
|
License: $(getMetadata 'License')
|
||||||
|
|
@ -269,22 +269,22 @@ exists() {
|
||||||
# Pretty print methods.
|
# Pretty print methods.
|
||||||
printInfo() {
|
printInfo() {
|
||||||
if [ "${quiet-}" != 'true' ]; then
|
if [ "${quiet-}" != 'true' ]; then
|
||||||
if [ "${color-}" != 'true' ]; then printf -- '[INFO] %s\n' "${@-}"
|
if [ "${color-}" != 'true' ]; then printf '[INFO] %s\n' "${@-}"
|
||||||
else printf -- '\033[0m[\033[1;32mINFO\033[0m] %s\n' "${@-}"; fi
|
else printf '\033[0m[\033[1;32mINFO\033[0m] %s\n' "${@-}"; fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
printWarn() {
|
printWarn() {
|
||||||
if [ "${color-}" != 'true' ]; then printf -- '[WARN] %s\n' "${@-}" >&2
|
if [ "${color-}" != 'true' ]; then printf '[WARN] %s\n' "${@-}" >&2
|
||||||
else printf -- '\033[0m[\033[1;33mWARN\033[0m] %s\n' "${@-}" >&2; fi
|
else printf '\033[0m[\033[1;33mWARN\033[0m] %s\n' "${@-}" >&2; fi
|
||||||
}
|
}
|
||||||
printError() {
|
printError() {
|
||||||
if [ "${color-}" != 'true' ]; then printf -- '[ERROR] %s\n' "${@-}" >&2
|
if [ "${color-}" != 'true' ]; then printf '[ERROR] %s\n' "${@-}" >&2
|
||||||
else printf -- '\033[0m[\033[1;31mERROR\033[0m] %s\n' "${@-}" >&2; fi
|
else printf '\033[0m[\033[1;31mERROR\033[0m] %s\n' "${@-}" >&2; fi
|
||||||
}
|
}
|
||||||
printList() {
|
printList() {
|
||||||
if [ "${quiet-}" != 'true' ]; then
|
if [ "${quiet-}" != 'true' ]; then
|
||||||
if [ "${color-}" != 'true' ]; then printf -- ' * %s\n' "${@-}"
|
if [ "${color-}" != 'true' ]; then printf ' * %s\n' "${@-}"
|
||||||
else printf -- '\033[0m \033[1;36m*\033[0m %s\n' "${@-}"; fi
|
else printf '\033[0m \033[1;36m*\033[0m %s\n' "${@-}"; fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,7 +297,7 @@ rand() {
|
||||||
mktempFile() {
|
mktempFile() {
|
||||||
# POSIX does not specify the mktemp utility, so here comes a hacky solution.
|
# POSIX does not specify the mktemp utility, so here comes a hacky solution.
|
||||||
while file="${TMPDIR:-${TMP:-/tmp}}/hblock.${$}.$(rand)" && [ -e "${file:?}" ]; do sleep 1; done
|
while file="${TMPDIR:-${TMP:-/tmp}}/hblock.${$}.$(rand)" && [ -e "${file:?}" ]; do sleep 1; done
|
||||||
(umask 077 && touch -- "${file:?}"); printf -- '%s' "${file:?}"
|
(umask 077 && touch -- "${file:?}"); printf '%s' "${file:?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Write stdin to a file.
|
# Write stdin to a file.
|
||||||
|
|
@ -461,7 +461,7 @@ main() {
|
||||||
|
|
||||||
# Parse command line options.
|
# Parse command line options.
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
{ optParse "${@-}"; set -- ${posArgs-}; }
|
{ optParse "${@-}"; set -- ${posArgs-} >/dev/null; }
|
||||||
|
|
||||||
if [ "${color:?}" = 'auto' ]; then
|
if [ "${color:?}" = 'auto' ]; then
|
||||||
# Check color support, but honor ${NO_COLOR} variable (https://no-color.org).
|
# Check color support, but honor ${NO_COLOR} variable (https://no-color.org).
|
||||||
|
|
@ -479,7 +479,7 @@ main() {
|
||||||
# If the file value equals "none", use an empty file.
|
# If the file value equals "none", use an empty file.
|
||||||
'none') headerFile="$(mktempFile)"; true > "${headerFile:?}" ;;
|
'none') headerFile="$(mktempFile)"; true > "${headerFile:?}" ;;
|
||||||
# If the file value equals "builtin", use the built-in value.
|
# If the file value equals "builtin", use the built-in value.
|
||||||
'builtin') headerFile="$(mktempFile)"; printf -- '%s' "${HBLOCK_HEADER_BUILTIN?}" > "${headerFile:?}" ;;
|
'builtin') headerFile="$(mktempFile)"; printf '%s' "${HBLOCK_HEADER_BUILTIN?}" > "${headerFile:?}" ;;
|
||||||
# If the file does not exist, throw an error.
|
# If the file does not exist, throw an error.
|
||||||
*) [ -e "${headerFile:?}" ] || { printError "No such file: ${headerFile:?}"; exit 1; } ;;
|
*) [ -e "${headerFile:?}" ] || { printError "No such file: ${headerFile:?}"; exit 1; } ;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -491,7 +491,7 @@ main() {
|
||||||
# If the file value equals "none", use an empty file.
|
# If the file value equals "none", use an empty file.
|
||||||
'none') footerFile="$(mktempFile)"; true > "${footerFile:?}" ;;
|
'none') footerFile="$(mktempFile)"; true > "${footerFile:?}" ;;
|
||||||
# If the file value equals "builtin", use the built-in value.
|
# If the file value equals "builtin", use the built-in value.
|
||||||
'builtin') footerFile="$(mktempFile)"; printf -- '%s' "${HBLOCK_FOOTER_BUILTIN?}" > "${footerFile:?}" ;;
|
'builtin') footerFile="$(mktempFile)"; printf '%s' "${HBLOCK_FOOTER_BUILTIN?}" > "${footerFile:?}" ;;
|
||||||
# If the file does not exist, throw an error.
|
# If the file does not exist, throw an error.
|
||||||
*) [ -e "${footerFile:?}" ] || { printError "No such file: ${footerFile:?}"; exit 1; } ;;
|
*) [ -e "${footerFile:?}" ] || { printError "No such file: ${footerFile:?}"; exit 1; } ;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -503,7 +503,7 @@ main() {
|
||||||
# If the file value equals "none", use an empty file.
|
# If the file value equals "none", use an empty file.
|
||||||
'none') sourcesFile="$(mktempFile)"; true > "${sourcesFile:?}" ;;
|
'none') sourcesFile="$(mktempFile)"; true > "${sourcesFile:?}" ;;
|
||||||
# If the file value equals "builtin", use the built-in value.
|
# If the file value equals "builtin", use the built-in value.
|
||||||
'builtin') sourcesFile="$(mktempFile)"; printf -- '%s' "${HBLOCK_SOURCES_BUILTIN?}" > "${sourcesFile:?}" ;;
|
'builtin') sourcesFile="$(mktempFile)"; printf '%s' "${HBLOCK_SOURCES_BUILTIN?}" > "${sourcesFile:?}" ;;
|
||||||
# If the file does not exist, throw an error.
|
# If the file does not exist, throw an error.
|
||||||
*) [ -e "${sourcesFile:?}" ] || { printError "No such file: ${sourcesFile:?}"; exit 1; } ;;
|
*) [ -e "${sourcesFile:?}" ] || { printError "No such file: ${sourcesFile:?}"; exit 1; } ;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -515,7 +515,7 @@ main() {
|
||||||
# If the file value equals "none", use an empty file.
|
# If the file value equals "none", use an empty file.
|
||||||
'none') allowlistFile="$(mktempFile)"; true > "${allowlistFile:?}" ;;
|
'none') allowlistFile="$(mktempFile)"; true > "${allowlistFile:?}" ;;
|
||||||
# If the file value equals "builtin", use the built-in value.
|
# If the file value equals "builtin", use the built-in value.
|
||||||
'builtin') allowlistFile="$(mktempFile)"; printf -- '%s' "${HBLOCK_ALLOWLIST_BUILTIN?}" > "${allowlistFile:?}" ;;
|
'builtin') allowlistFile="$(mktempFile)"; printf '%s' "${HBLOCK_ALLOWLIST_BUILTIN?}" > "${allowlistFile:?}" ;;
|
||||||
# If the file does not exist, throw an error.
|
# If the file does not exist, throw an error.
|
||||||
*) [ -e "${allowlistFile:?}" ] || { printError "No such file: ${allowlistFile:?}"; exit 1; } ;;
|
*) [ -e "${allowlistFile:?}" ] || { printError "No such file: ${allowlistFile:?}"; exit 1; } ;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -527,7 +527,7 @@ main() {
|
||||||
# If the file value equals "none", use an empty file.
|
# If the file value equals "none", use an empty file.
|
||||||
'none') denylistFile="$(mktempFile)"; true > "${denylistFile:?}" ;;
|
'none') denylistFile="$(mktempFile)"; true > "${denylistFile:?}" ;;
|
||||||
# If the file value equals "builtin", use the built-in value.
|
# If the file value equals "builtin", use the built-in value.
|
||||||
'builtin') denylistFile="$(mktempFile)"; printf -- '%s' "${HBLOCK_DENYLIST_BUILTIN?}" > "${denylistFile:?}" ;;
|
'builtin') denylistFile="$(mktempFile)"; printf '%s' "${HBLOCK_DENYLIST_BUILTIN?}" > "${denylistFile:?}" ;;
|
||||||
# If the file does not exist, throw an error.
|
# If the file does not exist, throw an error.
|
||||||
*) [ -e "${denylistFile:?}" ] || { printError "No such file: ${denylistFile:?}"; exit 1; } ;;
|
*) [ -e "${denylistFile:?}" ] || { printError "No such file: ${denylistFile:?}"; exit 1; } ;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -658,23 +658,23 @@ main() {
|
||||||
|
|
||||||
# If the header file is not empty, it is appended to the output file.
|
# If the header file is not empty, it is appended to the output file.
|
||||||
if [ -s "${headerFile:?}" ]; then
|
if [ -s "${headerFile:?}" ]; then
|
||||||
[ -z "${C?}" ] || printf -- '\n%s\n' "${C?} BEGIN HEADER"
|
[ -z "${C?}" ] || printf '\n%s\n' "${C?} BEGIN HEADER"
|
||||||
awk 1 < "${headerFile:?}"
|
awk 1 < "${headerFile:?}"
|
||||||
[ -z "${C?}" ] || printf -- '%s\n' "${C?} END HEADER"
|
[ -z "${C?}" ] || printf '%s\n' "${C?} END HEADER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the blocklist file is not empty, it is appended to the output file.
|
# If the blocklist file is not empty, it is appended to the output file.
|
||||||
if [ -s "${blocklistFile:?}" ]; then
|
if [ -s "${blocklistFile:?}" ]; then
|
||||||
[ -z "${C?}" ] || printf -- '\n%s\n' "${C?} BEGIN BLOCKLIST"
|
[ -z "${C?}" ] || printf '\n%s\n' "${C?} BEGIN BLOCKLIST"
|
||||||
awk 1 < "${blocklistFile:?}"
|
awk 1 < "${blocklistFile:?}"
|
||||||
[ -z "${C?}" ] || printf -- '%s\n' "${C?} END BLOCKLIST"
|
[ -z "${C?}" ] || printf '%s\n' "${C?} END BLOCKLIST"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the footer file is not empty, it is appended to the output file.
|
# If the footer file is not empty, it is appended to the output file.
|
||||||
if [ -s "${footerFile:?}" ]; then
|
if [ -s "${footerFile:?}" ]; then
|
||||||
[ -z "${C?}" ] || printf -- '\n%s\n' "${C?} BEGIN FOOTER"
|
[ -z "${C?}" ] || printf '\n%s\n' "${C?} BEGIN FOOTER"
|
||||||
awk 1 < "${footerFile:?}"
|
awk 1 < "${footerFile:?}"
|
||||||
[ -z "${C?}" ] || printf -- '%s\n' "${C?} END FOOTER"
|
[ -z "${C?}" ] || printf '%s\n' "${C?} END FOOTER"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ sha256Checksum() {
|
||||||
|
|
||||||
# Escape string for use in HTML.
|
# Escape string for use in HTML.
|
||||||
escapeHTML() {
|
escapeHTML() {
|
||||||
printf -- '%s' "${1?}" | awk -v RS='' "$(cat <<-'EOF'
|
printf '%s' "${1?}" | awk -v RS='' "$(cat <<-'EOF'
|
||||||
{
|
{
|
||||||
gsub(/&/, "\\&")
|
gsub(/&/, "\\&")
|
||||||
gsub(/</, "\\<")
|
gsub(/</, "\\<")
|
||||||
|
|
@ -60,7 +60,7 @@ escapeHTML() {
|
||||||
# RFC 3986 compliant URL encoding method.
|
# RFC 3986 compliant URL encoding method.
|
||||||
encodeURI() {
|
encodeURI() {
|
||||||
_LC_COLLATE="${LC_COLLATE-}"; LC_COLLATE='C'
|
_LC_COLLATE="${LC_COLLATE-}"; LC_COLLATE='C'
|
||||||
hex="$(printf -- '%s' "${1?}" | base16Encode | sed 's|\(.\{2\}\)|\1 |g')"
|
hex="$(printf '%s' "${1?}" | base16Encode | sed 's|\(.\{2\}\)|\1 |g')"
|
||||||
for h in ${hex?}; do
|
for h in ${hex?}; do
|
||||||
case "${h:?}" in
|
case "${h:?}" in
|
||||||
3[0-9]|\
|
3[0-9]|\
|
||||||
|
|
@ -76,7 +76,7 @@ encodeURI() {
|
||||||
|
|
||||||
# Calculate digest for Content-Security-Policy.
|
# Calculate digest for Content-Security-Policy.
|
||||||
cspDigest() {
|
cspDigest() {
|
||||||
hex="$(printf -- '%s' "${1?}" | sha256Checksum | sed 's|\(.\{2\}\)|\1 |g')"
|
hex="$(printf '%s' "${1?}" | sha256Checksum | sed 's|\(.\{2\}\)|\1 |g')"
|
||||||
b64="$(for h in ${hex?}; do printf '%b' '\0'"$(printf '%o' "0x${h:?}")"; done | base64Encode)"
|
b64="$(for h in ${hex?}; do printf '%b' '\0'"$(printf '%o' "0x${h:?}")"; done | base64Encode)"
|
||||||
printf 'sha256-%s' "${b64?}"
|
printf 'sha256-%s' "${b64?}"
|
||||||
}
|
}
|
||||||
|
|
@ -114,7 +114,7 @@ main() {
|
||||||
directory="${1:-./}"
|
directory="${1:-./}"
|
||||||
|
|
||||||
if [ ! -d "${directory:?}" ] || [ ! -r "${directory:?}" ]; then
|
if [ ! -d "${directory:?}" ] || [ ! -r "${directory:?}" ]; then
|
||||||
printf -- '%s\n' "Cannot read directory: '${directory:?}'" >&2
|
printf '%s\n' "Cannot read directory: '${directory:?}'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ main() {
|
||||||
fileDate="$(getFileModificationTime "${file:?}")"
|
fileDate="$(getFileModificationTime "${file:?}")"
|
||||||
escapedFileDate="$(escapeHTML "${fileDate:?}")"
|
escapedFileDate="$(escapeHTML "${fileDate:?}")"
|
||||||
|
|
||||||
printf -- '%s\n' "$(cat <<-EOF
|
printf '%s\n' "$(cat <<-EOF
|
||||||
<a class="row" href="./${escapedFileNameURI:?}" title="${escapedFileName:?}">
|
<a class="row" href="./${escapedFileNameURI:?}" title="${escapedFileName:?}">
|
||||||
<div class="cell">${escapedFileName:?}</div>
|
<div class="cell">${escapedFileName:?}</div>
|
||||||
<div class="cell">${escapedFileSize:?}</div>
|
<div class="cell">${escapedFileSize:?}</div>
|
||||||
|
|
@ -345,7 +345,7 @@ main() {
|
||||||
)"
|
)"
|
||||||
|
|
||||||
# HTML.
|
# HTML.
|
||||||
printf -- '%s\n' "$(tr -d '\n' <<-EOF
|
printf '%s\n' "$(tr -d '\n' <<-EOF
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Maintainer: Héctor Molinero Fernández <hector@molinero.dev>
|
# Maintainer: Héctor Molinero Fernández <hector@molinero.dev>
|
||||||
pkgname='hblock'
|
pkgname='hblock'
|
||||||
pkgver='m4_esyscmd(printf -- '%s' "${PKG_VERSION?}")'
|
pkgver='m4_esyscmd(printf '%s' "${PKG_VERSION?}")'
|
||||||
pkgrel='0'
|
pkgrel='0'
|
||||||
pkgdesc='Adblocker that creates a hosts file from multiple sources'
|
pkgdesc='Adblocker that creates a hosts file from multiple sources'
|
||||||
url='https://github.com/hectorm/hblock'
|
url='https://github.com/hectorm/hblock'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
m4_changequote([[, ]])m4_dnl
|
m4_changequote([[, ]])m4_dnl
|
||||||
hblock (m4_esyscmd(printf -- '%s' "${PKG_VERSION?}")) unstable; urgency=medium
|
hblock (m4_esyscmd(printf '%s' "${PKG_VERSION?}")) unstable; urgency=medium
|
||||||
|
|
||||||
* m4_esyscmd(printf -- '%s' "${PKG_VERSION?}") release.
|
* m4_esyscmd(printf '%s' "${PKG_VERSION?}") release.
|
||||||
|
|
||||||
-- Héctor Molinero Fernández <hector@molinero.dev> m4_esyscmd(date -Ru)
|
-- Héctor Molinero Fernández <hector@molinero.dev> m4_esyscmd(date -Ru)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
m4_changequote([[, ]])m4_dnl
|
m4_changequote([[, ]])m4_dnl
|
||||||
{
|
{
|
||||||
"name": "hblock",
|
"name": "hblock",
|
||||||
"version": "m4_esyscmd(printf -- '%s' "${PKG_VERSION?}")",
|
"version": "m4_esyscmd(printf '%s' "${PKG_VERSION?}")",
|
||||||
"description": "Adblocker that creates a hosts file from multiple sources",
|
"description": "Adblocker that creates a hosts file from multiple sources",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"ad-block",
|
"ad-block",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Maintainer: Héctor Molinero Fernández <hector@molinero.dev>
|
# Maintainer: Héctor Molinero Fernández <hector@molinero.dev>
|
||||||
pkgname='hblock'
|
pkgname='hblock'
|
||||||
pkgver='m4_esyscmd(printf -- '%s' "${PKG_VERSION?}")'
|
pkgver='m4_esyscmd(printf '%s' "${PKG_VERSION?}")'
|
||||||
pkgrel='1'
|
pkgrel='1'
|
||||||
pkgdesc='Adblocker that creates a hosts file from multiple sources'
|
pkgdesc='Adblocker that creates a hosts file from multiple sources'
|
||||||
arch=('any')
|
arch=('any')
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
m4_changequote([[, ]])m4_dnl
|
m4_changequote([[, ]])m4_dnl
|
||||||
%define name hblock
|
%define name hblock
|
||||||
%define version m4_esyscmd(printf -- '%s' "${PKG_VERSION?}")
|
%define version m4_esyscmd(printf '%s' "${PKG_VERSION?}")
|
||||||
|
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
Version: %{version}
|
Version: %{version}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ rand() {
|
||||||
mktempFile() {
|
mktempFile() {
|
||||||
# POSIX does not specify the mktemp utility, so here comes a hacky solution.
|
# POSIX does not specify the mktemp utility, so here comes a hacky solution.
|
||||||
while file="${TMPDIR:-${TMP:-/tmp}}/hblock.${$}.$(rand)" && [ -e "${file:?}" ]; do sleep 1; done
|
while file="${TMPDIR:-${TMP:-/tmp}}/hblock.${$}.$(rand)" && [ -e "${file:?}" ]; do sleep 1; done
|
||||||
(umask 077 && touch -- "${file:?}"); printf -- '%s' "${file:?}"
|
(umask 077 && touch -- "${file:?}"); printf '%s' "${file:?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Write stdin to a file.
|
# Write stdin to a file.
|
||||||
|
|
@ -69,7 +69,7 @@ main() {
|
||||||
pslUrl="${2:-https://publicsuffix.org/list/public_suffix_list.dat}"
|
pslUrl="${2:-https://publicsuffix.org/list/public_suffix_list.dat}"
|
||||||
|
|
||||||
if [ ! -e "${domainsFile:?}" ]; then
|
if [ ! -e "${domainsFile:?}" ]; then
|
||||||
printf -- '%s\n' "No such file: '${domainsFile:?}'" >&2
|
printf '%s\n' "No such file: '${domainsFile:?}'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ main() {
|
||||||
while IFS= read -r suffix || [ -n "${suffix?}" ]; do
|
while IFS= read -r suffix || [ -n "${suffix?}" ]; do
|
||||||
if grep -- "${suffix:?}" "${workFile:?}" > "${matchFile:?}"; then
|
if grep -- "${suffix:?}" "${workFile:?}" > "${matchFile:?}"; then
|
||||||
count="$(awk '{N+=$1}END{print(N)}' < "${matchFile:?}")"
|
count="$(awk '{N+=$1}END{print(N)}' < "${matchFile:?}")"
|
||||||
printf -- '%s\t%s\n' "${count:?}" "${suffix:?}" >> "${statsFile:?}"
|
printf '%s\t%s\n' "${count:?}" "${suffix:?}" >> "${statsFile:?}"
|
||||||
{ grep -v -- "${suffix:?}" "${workFile:?}" ||:; } | sponge "${workFile:?}"
|
{ grep -v -- "${suffix:?}" "${workFile:?}" ||:; } | sponge "${workFile:?}"
|
||||||
fi
|
fi
|
||||||
done < "${pslFile:?}"
|
done < "${pslFile:?}"
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ runInTestShell() {
|
||||||
assertEquals() {
|
assertEquals() {
|
||||||
actual="${1?}"; expected="${2?}"
|
actual="${1?}"; expected="${2?}"
|
||||||
if [ "${actual?}" != "${expected?}" ]; then
|
if [ "${actual?}" != "${expected?}" ]; then
|
||||||
printf -- '\nError, values are not equal\n\n' >&2
|
printf '\nError, values are not equal\n\n' >&2
|
||||||
printf -- '[Actual]:\n\n%s\n\n' "${actual?}" >&2
|
printf '[Actual]:\n\n%s\n\n' "${actual?}" >&2
|
||||||
printf -- '[Expected]:\n\n%s\n\n' "${expected?}" >&2
|
printf '[Expected]:\n\n%s\n\n' "${expected?}" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
|
||||||
main() {
|
main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
|
|
||||||
printf -- 'Test - Main - Argument: Double dash argument\n'
|
printf 'Test - Main - Argument: Double dash argument\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -- -v)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -- -v)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
|
||||||
main() {
|
main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
|
|
||||||
printf -- 'Test - Main - Argument: Invalid long option\n'
|
printf 'Test - Main - Argument: Invalid long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --invalid='VALUE')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --invalid='VALUE')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
|
||||||
main() {
|
main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
|
|
||||||
printf -- 'Test - Main - Argument: Invalid short option\n'
|
printf 'Test - Main - Argument: Invalid short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -i 'VALUE')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -i 'VALUE')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -16,63 +16,63 @@ main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
export HBLOCK_ALLOWLIST_FILE=''
|
export HBLOCK_ALLOWLIST_FILE=''
|
||||||
|
|
||||||
printf -- 'Test - Main - Allowlist: "-A" short option\n'
|
printf 'Test - Main - Allowlist: "-A" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -A "${SCRIPT_DIR:?}/allowlist.txt")"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -A "${SCRIPT_DIR:?}/allowlist.txt")"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Allowlist: "--allowlist" long option\n'
|
printf 'Test - Main - Allowlist: "--allowlist" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist="${SCRIPT_DIR:?}/allowlist.txt")"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist="${SCRIPT_DIR:?}/allowlist.txt")"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Allowlist: "--allowlist" long option with "builtin" value\n'
|
printf 'Test - Main - Allowlist: "--allowlist" long option with "builtin" value\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='builtin')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='builtin')"
|
||||||
expected="$(cat -- "${0%.sh}"-builtin.out)"
|
expected="$(cat -- "${0%.sh}"-builtin.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Allowlist: "--allowlist" long option with "none" value\n'
|
printf 'Test - Main - Allowlist: "--allowlist" long option with "none" value\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='none')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='none')"
|
||||||
expected="$(cat -- "${0%.sh}"-none.out)"
|
expected="$(cat -- "${0%.sh}"-none.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Allowlist: "--allowlist" long option with "-" value\n'
|
printf 'Test - Main - Allowlist: "--allowlist" long option with "-" value\n'
|
||||||
actual="$(cat -- "${SCRIPT_DIR:?}/allowlist.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='-')"
|
actual="$(cat -- "${SCRIPT_DIR:?}/allowlist.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='-')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Allowlist: "--allowlist" long option with a non-existent file\n'
|
printf 'Test - Main - Allowlist: "--allowlist" long option with a non-existent file\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='/hblock/invalid.txt')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --allowlist='/hblock/invalid.txt')"
|
||||||
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Allowlist: "HBLOCK_ALLOWLIST_FILE" environment variable\n'
|
printf 'Test - Main - Allowlist: "HBLOCK_ALLOWLIST_FILE" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_ALLOWLIST_FILE="${SCRIPT_DIR:?}/allowlist.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_ALLOWLIST_FILE="${SCRIPT_DIR:?}/allowlist.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Allowlist: "HBLOCK_ALLOWLIST_FILE" environment variable with a non-existent file\n'
|
printf 'Test - Main - Allowlist: "HBLOCK_ALLOWLIST_FILE" environment variable with a non-existent file\n'
|
||||||
actual="$(set -a; HBLOCK_ALLOWLIST_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_ALLOWLIST_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Allowlist: "HBLOCK_ALLOWLIST" environment variable\n'
|
printf 'Test - Main - Allowlist: "HBLOCK_ALLOWLIST" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_ALLOWLIST="$(cat -- "${SCRIPT_DIR:?}/allowlist.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_ALLOWLIST="$(cat -- "${SCRIPT_DIR:?}/allowlist.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,21 @@ main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
export HBLOCK_COMMENT='#'
|
export HBLOCK_COMMENT='#'
|
||||||
|
|
||||||
printf -- 'Test - Main - Comment: "-C" short option\n'
|
printf 'Test - Main - Comment: "-C" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -C '# %')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -C '# %')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Comment: "--comment" long option\n'
|
printf 'Test - Main - Comment: "--comment" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --comment='# %')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --comment='# %')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Comment: "HBLOCK_COMMENT" environment variable\n'
|
printf 'Test - Main - Comment: "HBLOCK_COMMENT" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_COMMENT='# %' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_COMMENT='# %' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -16,63 +16,63 @@ main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
export HBLOCK_DENYLIST_FILE=''
|
export HBLOCK_DENYLIST_FILE=''
|
||||||
|
|
||||||
printf -- 'Test - Main - Denylist: "-D" short option\n'
|
printf 'Test - Main - Denylist: "-D" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -D "${SCRIPT_DIR:?}/denylist.txt")"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -D "${SCRIPT_DIR:?}/denylist.txt")"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Denylist: "--denylist" long option\n'
|
printf 'Test - Main - Denylist: "--denylist" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist="${SCRIPT_DIR:?}/denylist.txt")"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist="${SCRIPT_DIR:?}/denylist.txt")"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Denylist: "--denylist" long option with "builtin" value\n'
|
printf 'Test - Main - Denylist: "--denylist" long option with "builtin" value\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='builtin')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='builtin')"
|
||||||
expected="$(cat -- "${0%.sh}"-builtin.out)"
|
expected="$(cat -- "${0%.sh}"-builtin.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Denylist: "--denylist" long option with "none" value\n'
|
printf 'Test - Main - Denylist: "--denylist" long option with "none" value\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='none')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='none')"
|
||||||
expected="$(cat -- "${0%.sh}"-none.out)"
|
expected="$(cat -- "${0%.sh}"-none.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Denylist: "--denylist" long option with "-" value\n'
|
printf 'Test - Main - Denylist: "--denylist" long option with "-" value\n'
|
||||||
actual="$(cat -- "${SCRIPT_DIR:?}/denylist.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='-')"
|
actual="$(cat -- "${SCRIPT_DIR:?}/denylist.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='-')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Denylist: "--denylist" long option with a non-existent file\n'
|
printf 'Test - Main - Denylist: "--denylist" long option with a non-existent file\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='/hblock/invalid.txt')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --denylist='/hblock/invalid.txt')"
|
||||||
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Denylist: "HBLOCK_DENYLIST_FILE" environment variable\n'
|
printf 'Test - Main - Denylist: "HBLOCK_DENYLIST_FILE" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_DENYLIST_FILE="${SCRIPT_DIR:?}/denylist.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_DENYLIST_FILE="${SCRIPT_DIR:?}/denylist.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Denylist: "HBLOCK_DENYLIST_FILE" environment variable with a non-existent file\n'
|
printf 'Test - Main - Denylist: "HBLOCK_DENYLIST_FILE" environment variable with a non-existent file\n'
|
||||||
actual="$(set -a; HBLOCK_DENYLIST_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_DENYLIST_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Denylist: "HBLOCK_DENYLIST" environment variable\n'
|
printf 'Test - Main - Denylist: "HBLOCK_DENYLIST" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_DENYLIST="$(cat -- "${SCRIPT_DIR:?}/denylist.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_DENYLIST="$(cat -- "${SCRIPT_DIR:?}/denylist.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,21 @@ main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
export HBLOCK_FILTER_SUBDOMAINS='false'
|
export HBLOCK_FILTER_SUBDOMAINS='false'
|
||||||
|
|
||||||
printf -- 'Test - Main - Filter subdomains: "-f" short option\n'
|
printf 'Test - Main - Filter subdomains: "-f" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -f)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -f)"
|
||||||
expected="$(cat -- "${0%.sh}"-true.out)"
|
expected="$(cat -- "${0%.sh}"-true.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Filter subdomains: "--filter-subdomains" long option\n'
|
printf 'Test - Main - Filter subdomains: "--filter-subdomains" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --filter-subdomains)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --filter-subdomains)"
|
||||||
expected="$(cat -- "${0%.sh}"-true.out)"
|
expected="$(cat -- "${0%.sh}"-true.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Filter subdomains: "HBLOCK_FILTER_SUBDOMAINS" environment variable\n'
|
printf 'Test - Main - Filter subdomains: "HBLOCK_FILTER_SUBDOMAINS" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_FILTER_SUBDOMAINS='true' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_FILTER_SUBDOMAINS='true' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}"-true.out)"
|
expected="$(cat -- "${0%.sh}"-true.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
@ -39,7 +39,7 @@ main() {
|
||||||
|
|
||||||
export HBLOCK_FILTER_SUBDOMAINS='true'
|
export HBLOCK_FILTER_SUBDOMAINS='true'
|
||||||
|
|
||||||
printf -- 'Test - Main - Filter subdomains: "--no-filter-subdomains" long option\n'
|
printf 'Test - Main - Filter subdomains: "--no-filter-subdomains" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --no-filter-subdomains)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --no-filter-subdomains)"
|
||||||
expected="$(cat -- "${0%.sh}"-false.out)"
|
expected="$(cat -- "${0%.sh}"-false.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -16,63 +16,63 @@ main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
export HBLOCK_FOOTER_FILE=''
|
export HBLOCK_FOOTER_FILE=''
|
||||||
|
|
||||||
printf -- 'Test - Main - Footer: "-F" short option\n'
|
printf 'Test - Main - Footer: "-F" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -F "${SCRIPT_DIR:?}/footer.txt")"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -F "${SCRIPT_DIR:?}/footer.txt")"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Footer: "--footer" long option\n'
|
printf 'Test - Main - Footer: "--footer" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer="${SCRIPT_DIR:?}/footer.txt")"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer="${SCRIPT_DIR:?}/footer.txt")"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Footer: "--footer" long option with "builtin" value\n'
|
printf 'Test - Main - Footer: "--footer" long option with "builtin" value\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='builtin')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='builtin')"
|
||||||
expected="$(cat -- "${0%.sh}"-builtin.out)"
|
expected="$(cat -- "${0%.sh}"-builtin.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Footer: "--footer" long option with "none" value\n'
|
printf 'Test - Main - Footer: "--footer" long option with "none" value\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='none')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='none')"
|
||||||
expected="$(cat -- "${0%.sh}"-none.out)"
|
expected="$(cat -- "${0%.sh}"-none.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Footer: "--footer" long option with "-" value\n'
|
printf 'Test - Main - Footer: "--footer" long option with "-" value\n'
|
||||||
actual="$(cat -- "${SCRIPT_DIR:?}/footer.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='-')"
|
actual="$(cat -- "${SCRIPT_DIR:?}/footer.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='-')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Footer: "--footer" long option with a non-existent file\n'
|
printf 'Test - Main - Footer: "--footer" long option with a non-existent file\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='/hblock/invalid.txt')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --footer='/hblock/invalid.txt')"
|
||||||
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Footer: "HBLOCK_FOOTER_FILE" environment variable\n'
|
printf 'Test - Main - Footer: "HBLOCK_FOOTER_FILE" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_FOOTER_FILE="${SCRIPT_DIR:?}/footer.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_FOOTER_FILE="${SCRIPT_DIR:?}/footer.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Footer: "HBLOCK_FOOTER_FILE" environment variable with a non-existent file\n'
|
printf 'Test - Main - Footer: "HBLOCK_FOOTER_FILE" environment variable with a non-existent file\n'
|
||||||
actual="$(set -a; HBLOCK_FOOTER_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_FOOTER_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Footer: "HBLOCK_FOOTER" environment variable\n'
|
printf 'Test - Main - Footer: "HBLOCK_FOOTER" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_FOOTER="$(cat -- "${SCRIPT_DIR:?}/footer.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_FOOTER="$(cat -- "${SCRIPT_DIR:?}/footer.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -16,63 +16,63 @@ main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
export HBLOCK_HEADER_FILE=''
|
export HBLOCK_HEADER_FILE=''
|
||||||
|
|
||||||
printf -- 'Test - Main - Header: "-H" short option\n'
|
printf 'Test - Main - Header: "-H" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -H "${SCRIPT_DIR:?}/header.txt")"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -H "${SCRIPT_DIR:?}/header.txt")"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Header: "--header" long option\n'
|
printf 'Test - Main - Header: "--header" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header="${SCRIPT_DIR:?}/header.txt")"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header="${SCRIPT_DIR:?}/header.txt")"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Header: "--header" long option with "builtin" value\n'
|
printf 'Test - Main - Header: "--header" long option with "builtin" value\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='builtin')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='builtin')"
|
||||||
expected="$(cat -- "${0%.sh}"-builtin.out)"
|
expected="$(cat -- "${0%.sh}"-builtin.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Header: "--header" long option with "none" value\n'
|
printf 'Test - Main - Header: "--header" long option with "none" value\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='none')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='none')"
|
||||||
expected="$(cat -- "${0%.sh}"-none.out)"
|
expected="$(cat -- "${0%.sh}"-none.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Header: "--header" long option with "-" value\n'
|
printf 'Test - Main - Header: "--header" long option with "-" value\n'
|
||||||
actual="$(cat -- "${SCRIPT_DIR:?}/header.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='-')"
|
actual="$(cat -- "${SCRIPT_DIR:?}/header.txt" | runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='-')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Header: "--header" long option with a non-existent file\n'
|
printf 'Test - Main - Header: "--header" long option with a non-existent file\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='/hblock/invalid.txt')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --header='/hblock/invalid.txt')"
|
||||||
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Header: "HBLOCK_HEADER_FILE" environment variable\n'
|
printf 'Test - Main - Header: "HBLOCK_HEADER_FILE" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_HEADER_FILE="${SCRIPT_DIR:?}/header.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_HEADER_FILE="${SCRIPT_DIR:?}/header.txt" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Header: "HBLOCK_HEADER_FILE" environment variable with a non-existent file\n'
|
printf 'Test - Main - Header: "HBLOCK_HEADER_FILE" environment variable with a non-existent file\n'
|
||||||
actual="$(set -a; HBLOCK_HEADER_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_HEADER_FILE='/hblock/invalid.txt' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
expected="$(cat -- "${0%.sh}"-invalid.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Header: "HBLOCK_HEADER" environment variable\n'
|
printf 'Test - Main - Header: "HBLOCK_HEADER" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_HEADER="$(cat -- "${SCRIPT_DIR:?}/header.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_HEADER="$(cat -- "${SCRIPT_DIR:?}/header.txt")" runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,21 @@ main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
export HBLOCK_LENIENT='false'
|
export HBLOCK_LENIENT='false'
|
||||||
|
|
||||||
printf -- 'Test - Main - Lenient: "-l" short option\n'
|
printf 'Test - Main - Lenient: "-l" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -l)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -l)"
|
||||||
expected="$(cat -- "${0%.sh}"-true.out)"
|
expected="$(cat -- "${0%.sh}"-true.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Lenient: "--lenient" long option\n'
|
printf 'Test - Main - Lenient: "--lenient" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --lenient)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --lenient)"
|
||||||
expected="$(cat -- "${0%.sh}"-true.out)"
|
expected="$(cat -- "${0%.sh}"-true.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Lenient: "HBLOCK_LENIENT" environment variable\n'
|
printf 'Test - Main - Lenient: "HBLOCK_LENIENT" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_LENIENT='true' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_LENIENT='true' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}"-true.out)"
|
expected="$(cat -- "${0%.sh}"-true.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
@ -39,7 +39,7 @@ main() {
|
||||||
|
|
||||||
export HBLOCK_LENIENT='true'
|
export HBLOCK_LENIENT='true'
|
||||||
|
|
||||||
printf -- 'Test - Main - Lenient: "--no-lenient" long option\n'
|
printf 'Test - Main - Lenient: "--no-lenient" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --no-lenient)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --no-lenient)"
|
||||||
expected="$(cat -- "${0%.sh}"-false.out)"
|
expected="$(cat -- "${0%.sh}"-false.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,21 @@ main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
export HBLOCK_REDIRECTION='0.0.0.0'
|
export HBLOCK_REDIRECTION='0.0.0.0'
|
||||||
|
|
||||||
printf -- 'Test - Main - Redirection: "-R" short option\n'
|
printf 'Test - Main - Redirection: "-R" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -R '::1')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -R '::1')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Redirection: "--redirection" long option\n'
|
printf 'Test - Main - Redirection: "--redirection" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --redirection='::1')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --redirection='::1')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Redirection: "HBLOCK_REDIRECTION" environment variable\n'
|
printf 'Test - Main - Redirection: "HBLOCK_REDIRECTION" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_REDIRECTION='::1' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_REDIRECTION='::1' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -22,21 +22,21 @@ main() {
|
||||||
EOF
|
EOF
|
||||||
)"
|
)"
|
||||||
|
|
||||||
printf -- 'Test - Main - Regex: "-r" short option\n'
|
printf 'Test - Main - Regex: "-r" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -r)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -r)"
|
||||||
expected="$(cat -- "${0%.sh}"-true.out)"
|
expected="$(cat -- "${0%.sh}"-true.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Regex: "--regex" long option\n'
|
printf 'Test - Main - Regex: "--regex" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --regex)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --regex)"
|
||||||
expected="$(cat -- "${0%.sh}"-true.out)"
|
expected="$(cat -- "${0%.sh}"-true.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Regex: "HBLOCK_REGEX" environment variable\n'
|
printf 'Test - Main - Regex: "HBLOCK_REGEX" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_REGEX='true' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_REGEX='true' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}"-true.out)"
|
expected="$(cat -- "${0%.sh}"-true.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
@ -52,7 +52,7 @@ main() {
|
||||||
EOF
|
EOF
|
||||||
)"
|
)"
|
||||||
|
|
||||||
printf -- 'Test - Main - Regex: "--no-regex" long option\n'
|
printf 'Test - Main - Regex: "--no-regex" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --no-regex)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --no-regex)"
|
||||||
expected="$(cat -- "${0%.sh}"-false.out)"
|
expected="$(cat -- "${0%.sh}"-false.out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,21 @@ main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
export HBLOCK_TEMPLATE='%R %D'
|
export HBLOCK_TEMPLATE='%R %D'
|
||||||
|
|
||||||
printf -- 'Test - Main - Template: "-T" short option\n'
|
printf 'Test - Main - Template: "-T" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -T '%D\n\t└─ %R')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -T '%D\n\t└─ %R')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Template: "--template" long option\n'
|
printf 'Test - Main - Template: "--template" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --template='%D\n\t└─ %R')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --template='%D\n\t└─ %R')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Template: "HBLOCK_TEMPLATE" environment variable\n'
|
printf 'Test - Main - Template: "HBLOCK_TEMPLATE" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_TEMPLATE='%D\n\t└─ %R' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_TEMPLATE='%D\n\t└─ %R' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,21 @@ main() {
|
||||||
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
export HBLOCK_SOURCES="file://${SCRIPT_DIR:?}/test-domains-source.txt"
|
||||||
export HBLOCK_WRAP='1'
|
export HBLOCK_WRAP='1'
|
||||||
|
|
||||||
printf -- 'Test - Main - Wrap: "-W" short option\n'
|
printf 'Test - Main - Wrap: "-W" short option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -W '5')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- -W '5')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Wrap: "--wrap" long option\n'
|
printf 'Test - Main - Wrap: "--wrap" long option\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --wrap='5')"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO- --wrap='5')"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -- 'Test - Main - Wrap: "HBLOCK_WRAP" environment variable\n'
|
printf 'Test - Main - Wrap: "HBLOCK_WRAP" environment variable\n'
|
||||||
actual="$(set -a; HBLOCK_WRAP='5' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
actual="$(set -a; HBLOCK_WRAP='5' runInTestShell "${SCRIPT_DIR:?}/../../hblock" -qO-)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
|
||||||
. "${SCRIPT_DIR:?}"/env.sh
|
. "${SCRIPT_DIR:?}"/env.sh
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
printf -- 'Test - Stats: Suffixes\n'
|
printf 'Test - Stats: Suffixes\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../stats/stats.sh" "${SCRIPT_DIR:?}/test-domains-stats.txt" "file://${SCRIPT_DIR:?}/psl.txt")"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../stats/stats.sh" "${SCRIPT_DIR:?}/test-domains-stats.txt" "file://${SCRIPT_DIR:?}/psl.txt")"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)"
|
||||||
. "${SCRIPT_DIR:?}"/env.sh
|
. "${SCRIPT_DIR:?}"/env.sh
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
printf -- 'Test - Stats: TLDs\n'
|
printf 'Test - Stats: TLDs\n'
|
||||||
actual="$(runInTestShell "${SCRIPT_DIR:?}/../stats/stats.sh" "${SCRIPT_DIR:?}/test-domains-stats.txt" none)"
|
actual="$(runInTestShell "${SCRIPT_DIR:?}/../stats/stats.sh" "${SCRIPT_DIR:?}/test-domains-stats.txt" none)"
|
||||||
expected="$(cat -- "${0%.sh}".out)"
|
expected="$(cat -- "${0%.sh}".out)"
|
||||||
if ! assertEquals "${actual?}" "${expected?}"; then
|
if ! assertEquals "${actual?}" "${expected?}"; then
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ setVersion() {
|
||||||
make -C "${PROJECT_DIR:?}" man
|
make -C "${PROJECT_DIR:?}" man
|
||||||
|
|
||||||
# Regenerate checksum file.
|
# Regenerate checksum file.
|
||||||
printf -- '%s %s\n' "${hblockScriptChecksum:?}" 'hblock' > "${PROJECT_DIR:?}"/hblock.sha256
|
printf '%s %s\n' "${hblockScriptChecksum:?}" 'hblock' > "${PROJECT_DIR:?}"/hblock.sha256
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "${1:?}" = 'get' ]; then
|
if [ "${1:?}" = 'get' ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue