Skip to content

Commit 9318c2d

Browse files
author
SMKRV
committed
fix: Fix ShellCheck warnings
1 parent 8f27ab0 commit 9318c2d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

mikrotik-domain-filter-bash.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
14
# @license: CC BY-NC-SA 4.0 International
25
# @author: SMKRV
36
# @github: https://github.com/smkrv/mikrotik-domain-filter-script
@@ -17,9 +20,6 @@
1720
# domains serving advertisements, integrating seamlessly with DNS Static in
1821
# Mikrotik RouterOS, and aiding in generating DNS FWD records.
1922

20-
#!/bin/bash
21-
set -e
22-
2323
# Enable debugging
2424
# set -x
2525

@@ -59,8 +59,6 @@ export DNS_MAX_RETRIES
5959

6060
# Global variables for statistics
6161
declare -i TOTAL_DOMAINS=0
62-
declare -i PROCESSED_DOMAINS=0
63-
declare -i VALID_DOMAINS=0
6462

6563
# Enable debugging
6664
# exec 2>"${WORK_DIR}/debug.log"
@@ -71,7 +69,7 @@ mkdir -p "$(dirname "$LOG_FILE")"
7169
# Clear old log
7270
: > "$LOG_FILE"
7371

74-
# Check for required files
72+
# Check for required files
7573
check_required_files() {
7674
local missing_files=()
7775

@@ -87,7 +85,8 @@ check_required_files() {
8785

8886
# Enhanced logging
8987
log() {
90-
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
88+
local timestamp
89+
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
9190
echo "[$timestamp] $1" | tee -a "$LOG_FILE"
9291
}
9392

@@ -368,7 +367,8 @@ initial_filter() {
368367
# Function to determine domain type
369368
get_domain_type() {
370369
local domain=$1
371-
local parts=(${domain//./ })
370+
local parts
371+
IFS='.' read -ra parts <<< "$domain"
372372
local levels=${#parts[@]}
373373
local base="${parts[-2]}.${parts[-1]}"
374374

@@ -525,7 +525,7 @@ apply_whitelist() {
525525

526526
# Create temporary file for exclusion patterns
527527
local whitelist_pattern="${TMP_DIR}/whitelist_pattern.txt"
528-
> "$whitelist_pattern"
528+
true > "$whitelist_pattern"
529529

530530
# Process whitelist
531531
while IFS= read -r domain; do

0 commit comments

Comments
 (0)