#1106335 grep: non-sensical matches - "over-matching"

Package:
grep
Source:
grep
Description:
GNU grep, egrep and fgrep
Submitter:
Sunny73Cr
Date:
2026-10-22 07:51:01 UTC
Severity:
normal
#1106335#5
Date:
2025-05-23 01:56:03 UTC
From:
To:
PATH_TEST="../../dir/dir/dir/dir/@#$%^&*()-_=+\\|;:'\",<.>/?/";
echo "$PATH_TEST" | grep "^\.\?\.\?\([a-zA-Z0-9@#$%^&*()-_=+\|;:'",<>/?]\+\)\+/\?$";

. is not within the character set portion of the match specification provided to grep.
../../ is matched; I expect it to match only '../', therefore no match for the line.
. is also matched in the ,<.> portion toward the end of the path.

SOURCE="[[]]";
echo "$SOURCE" | grep "[[]]\+"

The very first [ is not matched in this string.
grep "[\[\]]\+" does not match it either.

Regards,
sunny

#1106335#10
Date:
2025-05-23 02:17:18 UTC
From:
To:
System used is Debain 12.9, no updates.
Bash is the shell in use; it may play a part in interpreting "" strings.

Regards,
sunny

#1106335#15
Date:
2026-10-22 07:46:15 UTC
From:
To:
The 'bug' lies within my use of the - character within a character set; it should be last. Additionally, the regex is just bad. I am still unsure why the entire string matches if grep is used improperly.

My GitHub repository has a test using libpcre2, if anybody wished to do a sanity check in the future: https://github.com/sunny73cr/pcre_test