While answering another question, I quoted
man grep, in relation to
-x, --line-regexp Select only those matches that exactly match the whole line. For a regular expression pattern, this is like parenthesizing the pattern and then surrounding it with ^ and $.
I already knew that
-x was like "surrounding [the regex] with
$", but why does it also imply "parenthesizing the pattern"?
I can't think of why parenthesizing would be necessary, or even change anything. If the whole pattern were parenthesized, you couldn't refer to it internally with a capturing group.
grep complains about trailing backslashes, so there's no odd behaviour from an appended
) either (nor would I expect that to be in the spirit of an option).
man grep specifically mention
parenthesizing the pattern for