bazelbuild / bazel-skylib

Common useful functions and rules for Bazel
https://bazel.build/
Apache License 2.0
376 stars 179 forks source link

fix: Fix a bug in globs when middle is non-empty, but right is empty. #516

Closed matts1 closed 2 months ago

matts1 commented 2 months ago

For example, if you try to match `a" against "ab", then we check:

left = ""
middle = "a"
right = ""
middle in name[len(left):len(name)-len(right)]:
"a" in "ab"[len(""):len(name)-len("")]:
"a" in "ab"[0:-0]
"a" in "" => False

The problem here is that negative numbers in python index from the back, but -0 is not a negative number, so it always results in the empty string.