setup-ngxblocker: improve find_line() detection

* adds regex to ignore commented lines in vhost files
This commit is contained in:
Stuart Cardall 2017-09-20 13:45:25 +00:00
parent a4e9d4dcdc
commit 863bf14bab
No known key found for this signature in database
GPG key ID: AEB857F1C891D0C6

View file

@ -186,8 +186,9 @@ find_line() {
local file=$1 find_str=$2 first_last=$3
case "$first_last" in
first) awk "/$find_str/{ print NR; exit }" $file;;
last) awk "/$find_str/{ print NR }" $file | tail -n1;;
# ignore file #comments
first) grep -nE "^[ ]+$find_str" $file | head -n1 | awk -F: '{print $1}';;
last) grep -nE "^[ ]+$find_str" $file | tail -n1 | awk -F: '{print $1}';;
esac
}