mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-01 13:10:15 +00:00
restore the addKey comment, reworded for anchors
Per @dschaper, restore the addKey clarifying comment. It has been reworded to describe the use of anchors where before it referenced using grep's 'match only an entire line' argument. Signed-off-by: William Blew <william@kulian.org>
This commit is contained in:
parent
b9a6970bfd
commit
3c91b6558d
1 changed files with 4 additions and 0 deletions
|
@ -57,6 +57,10 @@ addKey(){
|
||||||
# touch file to prevent grep error if file does not exist yet
|
# touch file to prevent grep error if file does not exist yet
|
||||||
touch "${file}"
|
touch "${file}"
|
||||||
|
|
||||||
|
# Match key against entire line, using both anchors. We assume
|
||||||
|
# that the file's keys never have bounding whitespace. Anchors
|
||||||
|
# are necessary to ensure the key is considered absent when it
|
||||||
|
# is a substring of another key present in the file.
|
||||||
if ! grep -q "^${key}$" "${file}"; then
|
if ! grep -q "^${key}$" "${file}"; then
|
||||||
# Key does not exist, add it.
|
# Key does not exist, add it.
|
||||||
echo "${key}" >> "${file}"
|
echo "${key}" >> "${file}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue