From d4ac818a0b285672a7725bcf4b8ea75c0b13a229 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 21 Feb 2018 11:23:07 +0000 Subject: [PATCH 1/2] Specifty `LC_ALL=C` when dealing with sorted lists. Signed-off-by: Adam Warner --- gravity.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gravity.sh b/gravity.sh index ce2734fc..71849380 100755 --- a/gravity.sh +++ b/gravity.sh @@ -330,7 +330,7 @@ gravity_ParseFileIntoDomains() { }' "${source}" > "${destination}.exceptionsFile.tmp" # Remove exceptions - comm -23 "${destination}" <(sort "${destination}.exceptionsFile.tmp") > "${source}" + LC_ALL=C comm -23 "${destination}" <(sort "${destination}.exceptionsFile.tmp") > "${source}" mv "${source}" "${destination}" fi @@ -409,7 +409,7 @@ gravity_SortAndFilterConsolidatedList() { str="Removing duplicate domains" echo -ne " ${INFO} ${str}..." - sort -u "${piholeDir}/${parsedMatter}" > "${piholeDir}/${preEventHorizon}" + LC_ALL=C sort -u "${piholeDir}/${parsedMatter}" > "${piholeDir}/${preEventHorizon}" echo -e "${OVER} ${TICK} ${str}" # Format $preEventHorizon line total as currency @@ -431,7 +431,7 @@ gravity_Whitelist() { echo -ne " ${INFO} ${str}..." # Print everything from preEventHorizon into whitelistMatter EXCEPT domains in $whitelistFile - comm -23 "${piholeDir}/${preEventHorizon}" <(sort "${whitelistFile}") > "${piholeDir}/${whitelistMatter}" + LC_ALL=C comm -23 "${piholeDir}/${preEventHorizon}" <(sort "${whitelistFile}") > "${piholeDir}/${whitelistMatter}" echo -e "${OVER} ${INFO} ${str}" } From 6b4685b33308f426ecd7c2b591b0713132a32525 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 21 Feb 2018 11:33:29 +0000 Subject: [PATCH 2/2] much more elegant to export LC_ALL at the beginning of the script! Signed-off-by: Adam Warner --- gravity.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gravity.sh b/gravity.sh index 71849380..cfc7566e 100755 --- a/gravity.sh +++ b/gravity.sh @@ -11,6 +11,8 @@ # This file is copyright under the latest version of the EUPL. # Please see LICENSE file for your rights under this license. +export LC_ALL=C + coltable="/opt/pihole/COL_TABLE" source "${coltable}" @@ -330,7 +332,7 @@ gravity_ParseFileIntoDomains() { }' "${source}" > "${destination}.exceptionsFile.tmp" # Remove exceptions - LC_ALL=C comm -23 "${destination}" <(sort "${destination}.exceptionsFile.tmp") > "${source}" + comm -23 "${destination}" <(sort "${destination}.exceptionsFile.tmp") > "${source}" mv "${source}" "${destination}" fi @@ -409,7 +411,7 @@ gravity_SortAndFilterConsolidatedList() { str="Removing duplicate domains" echo -ne " ${INFO} ${str}..." - LC_ALL=C sort -u "${piholeDir}/${parsedMatter}" > "${piholeDir}/${preEventHorizon}" + sort -u "${piholeDir}/${parsedMatter}" > "${piholeDir}/${preEventHorizon}" echo -e "${OVER} ${TICK} ${str}" # Format $preEventHorizon line total as currency @@ -431,7 +433,7 @@ gravity_Whitelist() { echo -ne " ${INFO} ${str}..." # Print everything from preEventHorizon into whitelistMatter EXCEPT domains in $whitelistFile - LC_ALL=C comm -23 "${piholeDir}/${preEventHorizon}" <(sort "${whitelistFile}") > "${piholeDir}/${whitelistMatter}" + comm -23 "${piholeDir}/${preEventHorizon}" <(sort "${whitelistFile}") > "${piholeDir}/${whitelistMatter}" echo -e "${OVER} ${INFO} ${str}" }