Fix unbalanced parens in series-version regex (get_latest_installed_version)#184
Open
fsnow wants to merge 1 commit into
Open
Fix unbalanced parens in series-version regex (get_latest_installed_version)#184fsnow wants to merge 1 commit into
fsnow wants to merge 1 commit into
Conversation
The regex detecting a 2-part series (e.g. 8.3) had a typo: the character
class was written `[0-9)]` instead of `[0-9]+)`. That both drops the `+`
quantifier and swallows capture group 1's closing paren, leaving 3 open
parens and 2 close parens, so Bash rejects the regex outright:
m: line 1506: [[: invalid regular expression
`^([0-9)]\.([0-9]+)(-ent)?$': parentheses not balanced
The error prints on every path that reaches get_latest_installed_version,
including a plain `m 8.3.4` install, and breaks `m <major>.<minor>` series
resolution. Correct the class to `[0-9]+)` so group 1 captures the major
version as the following lines (BASH_REMATCH[1]/[2]) expect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
get_latest_installed_version()uses a regex to detect a 2-part series version (e.g.8.3) so it can resolve it to the latest installed patch. The regex has a typo — the first character class is written[0-9)]instead of[0-9]+):This does two things:
+quantifier on the major-version digits.The result is 3 opening parens but only 2 closing parens, so Bash rejects the whole regex at runtime:
Impact
m <major>.<minor>series resolution against installed versions is broken.get_latest_installed_version, including a plainm 8.3.4install, since the[[ =~ ]]test errors rather than returning false.Repro
Fix
Correct the character class to
[0-9]+)so group 1 captures the major version, matching how the following lines useBASH_REMATCH[1]/[2]:After the fix:
One-line change; no behavior change other than making the intended match work and silencing the error.