Closed debarshiray closed 1 year ago
Looks like a bug: your regex matches the empty string, so the exit code check in the or is not even called.
That means, all regexs that Match empty string are wrongly considered invalid.
Thanks for fixing this, @martin-schulze-vireso !
You were right. I overlooked that my regular expression was actually matching an empty string. I should have probably used +
instead of *
in the regexp.
Anyway, thanks again.
I don't know if this is a bug in bats-assert, or a mistake on my end, but it's odd enough that I decided to file it. Please let me know if I am doing things wrong.
We use regular expressions with Bats to assert SHA256 hashes in Toolbx, and I noticed that some seemingly valid extended regular expressions are being flagged as invalid. eg., this:
... will lead to:
This is the relevant code in bats-assert/src/assert_line.bash:
Initially, I thought that this is due to some escaping problem. So, I tried them directly in an interactive Bash session, and found something odd. The specific construct used in bats-assert to catch invalid extended regular expressions still triggers, but the expression otherwise works against a string:
So, I tried to tease it apart and found:
At this point, I have no idea why (and from where) the construct used in bats-assert gets 2 as a return status, and why another similar regular expression doesn't get flagged.