From 0efda049203a200ea8f19ce64ccf540d3a422de1 Mon Sep 17 00:00:00 2001 From: Marcus Hildum Date: Wed, 19 Oct 2016 20:46:37 -0700 Subject: [PATCH] Use heredocs instead of multiple calls to echo There were a lot of places (like in help functions) that used multiple echo calls instead of heredocs. Personal opinion but this seems cleaner. --- advanced/Scripts/blacklist.sh | 24 +++++++++++++----------- advanced/Scripts/chronometer.sh | 19 ++++++++++--------- advanced/Scripts/piholeDebug.sh | 14 ++++++++------ advanced/Scripts/version.sh | 28 +++++++++++++++------------- advanced/Scripts/whitelist.sh | 24 +++++++++++++----------- gravity.sh | 16 +++++++++------- 6 files changed, 68 insertions(+), 57 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index b7b9c360..dc815b58 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -11,17 +11,19 @@ # (at your option) any later version. helpFunc() { - echo "::: Immediately blacklists one or more domains in the hosts file" - echo ":::" - echo ":::" - echo "::: Usage: pihole -b domain1 [domain2 ...]" - echo "::: Options:" - echo "::: -d, --delmode Remove domains from the blacklist" - echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" - echo "::: -f, --force Force updating of the hosts files, even if there are no changes" - echo "::: -q, --quiet output is less verbose" - echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your blacklisted domains" + cat << EOM +::: Immediately blacklists one or more domains in the hosts file +::: +::: +::: Usage: pihole -b domain1 [domain2 ...] +::: Options: +::: -d, --delmode Remove domains from the blacklist +::: -nr, --noreload Update blacklist without refreshing dnsmasq +::: -f, --force Force updating of the hosts files, even if there are no changes +::: -q, --quiet output is less verbose +::: -h, --help Show this help dialog +::: -l, --list Display your blacklisted domains +EOM exit 1 } diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 28b7276e..c0b93e78 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -122,15 +122,16 @@ normalChrono() { } displayHelp() { - echo "::: Displays stats about your piHole!" - echo ":::" - echo "::: Usage: sudo pihole -c [optional:-j]" - echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds" - echo ":::" - echo "::: Options:" - echo "::: -j, --json output stats as JSON formatted string" - echo "::: -h, --help display this help text" - + cat << EOM +::: Displays stats about your piHole! +::: +::: Usage: sudo pihole -c [optional:-j] +::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds +::: +::: Options: +::: -j, --json output stats as JSON formatted string +::: -h, --help display this help text +EOM exit 1 } diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 287d03f6..a49133fd 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -27,12 +27,14 @@ PIHOLELOG="/var/log/pihole.log" WHITELISTMATCHES="/tmp/whitelistmatches.list" # Header info and introduction -echo "::: Beginning Pi-hole debug at $(date)!" -echo "::: This debugging process will collect information from your running configuration," -echo "::: and optionally upload the generated log to a unique and random directory on" -echo "::: Termbin.com. NOTE: All log files auto-delete after 1 month and you are the only" -echo "::: person who is given the unique URL. Please consider where you post this link." -echo "::: " +cat << EOM +::: Beginning Pi-hole debug at $(date)! +::: This debugging process will collect information from your running configuration, +::: and optionally upload the generated log to a unique and random directory on +::: Termbin.com. NOTE: All log files auto-delete after 1 month and you are the only +::: person who is given the unique URL. Please consider where you post this link. +::: +EOM ######## FIRST CHECK ######## diff --git a/advanced/Scripts/version.sh b/advanced/Scripts/version.sh index d749406e..7b2e3f68 100644 --- a/advanced/Scripts/version.sh +++ b/advanced/Scripts/version.sh @@ -72,19 +72,21 @@ coreOutput() { } helpFunc() { - echo ":::" - echo "::: Show Pi-hole/Web Admin versions" - echo ":::" - echo "::: Usage: pihole -v [ -a | -p ] [ -l | -c ]" - echo ":::" - echo "::: Options:" - echo "::: -a, --admin Show both current and latest versions of web admin" - echo "::: -p, --pihole Show both current and latest versions of Pi-hole core files" - echo "::: -l, --latest (Only after -a | -p) Return only latest version" - echo "::: -c, --current (Only after -a | -p) Return only current version" - echo "::: -h, --help Show this help dialog" - echo ":::" - exit 0 + cat << EOM +::: +::: Show Pi-hole/Web Admin versions +::: +::: Usage: pihole -v [ -a | -p ] [ -l | -c ] +::: +::: Options: +::: -a, --admin Show both current and latest versions of web admin +::: -p, --pihole Show both current and latest versions of Pi-hole core files +::: -l, --latest (Only after -a | -p) Return only latest version +::: -c, --current (Only after -a | -p) Return only current version +::: -h, --help Show this help dialog +::: +EOM + exit 1 } if [[ $# = 0 ]]; then diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 4f1aa0f3..ae4a7321 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -12,17 +12,19 @@ helpFunc() { - echo "::: Immediately whitelists one or more domains in the hosts file" - echo ":::" - echo "::: Usage: pihole -w domain1 [domain2 ...]" - echo ":::" - echo "::: Options:" - echo "::: -d, --delmode Remove domains from the whitelist" - echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq" - echo "::: -f, --force Force updating of the hosts files, even if there are no changes" - echo "::: -q, --quiet output is less verbose" - echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your whitelisted domains" + cat << EOM +::: Immediately whitelists one or more domains in the hosts file +::: +::: Usage: pihole -w domain1 [domain2 ...] +::: +::: Options: +::: -d, --delmode Remove domains from the whitelist +::: -nr, --noreload Update Whitelist without refreshing dnsmasq +::: -f, --force Force updating of the hosts files, even if there are no changes +::: -q, --quiet output is less verbose +::: -h, --help Show this help dialog +::: -l, --list Display your whitelisted domains +EOM exit 1 } diff --git a/gravity.sh b/gravity.sh index f781866d..607a5eba 100755 --- a/gravity.sh +++ b/gravity.sh @@ -14,13 +14,15 @@ echo ":::" helpFunc() { - echo "::: Pull in domains from adlists" - echo ":::" - echo "::: Usage: pihole -g" - echo ":::" - echo "::: Options:" - echo "::: -f, --force Force lists to be downloaded, even if they don't need updating." - echo "::: -h, --help Show this help dialog" + cat << EOM +::: Pull in domains from adlists +::: +::: Usage: pihole -g +::: +::: Options: +::: -f, --force Force lists to be downloaded, even if they don't need updating. +::: -h, --help Show this help dialog +EOM exit 1 }