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:
@@ -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}"
|
||||||
|
|||||||
Reference in New Issue
Block a user