From 258a035fd1d7698a42004825492f46bd1727e520 Mon Sep 17 00:00:00 2001 From: pvincent Date: Fri, 1 Apr 2022 10:46:59 +0400 Subject: [PATCH] fix: append_or_replace tabulation grep -P --- tools/append_or_replace | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/append_or_replace b/tools/append_or_replace index fe46f0d..cc41a73 100755 --- a/tools/append_or_replace +++ b/tools/append_or_replace @@ -13,8 +13,8 @@ REGEX=$1 STRING=$2 FILE=$3 -if ! grep -q "$REGEX" "$FILE"; then - PREFIX="" echo "$STRING" >>$FILE +if ! grep -Pq "$REGEX" "$FILE"; then + printf "$STRING\n" >>$FILE echo appended else sed -i "s|$REGEX|$STRING|g" $FILE