Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a problem with numbered environment variables #745

Merged
merged 1 commit into from
Oct 17, 2021

Conversation

jespino
Copy link
Contributor

@jespino jespino commented Oct 17, 2021

I found this problem here: go-task/task#586

I traced it to here. For some reason, the sorting + the binary search, were
behaving wrong. The inclusion of the = sign in the ordering looks like fixes
the problem. I'm not 100% sure why, maybe is again, an upstream bug.

I added a unit test to reproduce the problem.

Copy link
Owner

@mvdan mvdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, very nice catch! We rely on the list to be sorted for the binary search, and the binary search uses the = suffix to avoid the issue of "duplicate prefixes" like your GREETING and GREETING2. With the equals, GREETING= will never match the suffix of GREETING2=.

However, I forgot to also include the = suffix when sorting. So the two sort functions disagreed on the order of the items in this edge case.

@mvdan
Copy link
Owner

mvdan commented Oct 17, 2021

I'll merge on green, using a squash-merge to include the explanation of the fix in the commit message :)

@mvdan mvdan merged commit fb8587e into mvdan:master Oct 17, 2021
@mvdan mvdan added this to the 3.4.1 milestone Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants