From bbc392caeb631e46f840d1e87d6bebe07442545a Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 22 Feb 2019 22:49:02 +0100 Subject: [PATCH] More review comments Signed-off-by: DL6ER --- gravity.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 6ace8108..b09ddc0c 100755 --- a/gravity.sh +++ b/gravity.sh @@ -120,6 +120,7 @@ gravity_store_in_database() { tmpFile="$(mktemp -p "/tmp" --suffix=".gravity")" local timestamp timestamp="$(date --utc +'%s')" + local inputfile if [ "$table" == "whitelist" ] || [ "$table" == "blacklist" ] || [ "$table" == "regex" ]; then # Apply format for white-, blacklist, and regex tables # Read file line by line @@ -135,7 +136,7 @@ gravity_store_in_database() { # Store domains in gravity database table ${table} # Use printf as .mode and .import need to be on separate lines # see https://unix.stackexchange.com/a/445615/83260 - output=$( { printf ".mode csv\\n.import \"%s\" ${table}\\n" "${inputfile}" | sqlite3 "${gravityDBfile}"; } 2>&1 ) + output=$( { printf ".mode csv\\n.import \"%s\" %s\\n" "${inputfile}" "${table}" | sqlite3 "${gravityDBfile}"; } 2>&1 ) status="$?" if [[ "${status}" -ne 0 ]]; then @@ -144,7 +145,7 @@ gravity_store_in_database() { fi # Delete tmpfile - #rm "$tmpFile" > /dev/null 2>&1 || true + rm "$tmpFile" > /dev/null 2>&1 || true # Only create template file if asked to if [ "${template}" != "-" ]; then