Comment 94 for bug 1452202

Revision history for this message
Eric Desrochers (slashd) wrote :

IIUC,one of the goal mentioned by cyphermox here seems to avoid the grep cmd to catch ubuntu pattern where hostname has ubuntu in it.

Example:
sometextbeforeubuntusometextafter
ubuntusometextafter
sometextbeforeubuntu

and only catch it when it is 'ubuntu' nothing else.

I think "-w" should suffice to keep the if statement remove in Joshua' proposal.

# man grep
-w, --word-regexp
              Select only those lines containing matches that form whole words.

if ! echo "$RET" | grep -qw 'ubuntu'; then
or
if ! echo "$RET" | grep -q '\<ubuntu\>'; then

Some quick tests I quickly ran on my laptop :
# echo "beforeubuntuafter" | grep -w "ubuntu"
# echo "beforeubuntuafter" | grep -w "ubuntu"
# echo "ubuntuafter" | grep -w "ubuntu"
# echo "ubuntu" | grep -w "ubuntu"
ubuntu

That should cover at least that one item.

Thoughts ?

- Eric