From 4e35aa632d816187acc9cf31cf65b4ab042bedda Mon Sep 17 00:00:00 2001 From: Andrew Nowak Date: Wed, 6 Aug 2025 12:50:46 +0100 Subject: [PATCH] Make the add-to-hosts-file regex stricter to avoid incorrect matches --- script/add-to-hosts-file | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/add-to-hosts-file b/script/add-to-hosts-file index ff21482..e37357e 100755 --- a/script/add-to-hosts-file +++ b/script/add-to-hosts-file @@ -16,7 +16,7 @@ fi DOMAIN=$1 -if grep '127.0.0.1' /etc/hosts | grep ${DOMAIN} ; then +if grep -E "^127.0.0.1\\s+${DOMAIN}\\s*$" /etc/hosts ; then echo -e "✅ /etc/hosts entry already exists for ${DOMAIN}" else echo -e "🔧 ${YELLOW}adding /etc/hosts entry for ${DOMAIN}. Requires sudo - enter password when prompted.${NC}"