Skip to content

Commit 37e88d6

Browse files
[premain] Cleanup HYPERFINE_* environment variables that break caching.
1 parent 84477b9 commit 37e88d6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

sources/lib/premain.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ func PreMain () () {
5252
}
5353

5454

55+
for _, _variable := range os.Environ () {
56+
_accept := true
57+
if _splitIndex := strings.IndexByte (_variable, '='); _splitIndex >= 0 {
58+
_variable = _variable[:_splitIndex]
59+
if _variable == "" {
60+
_accept = false
61+
}
62+
} else {
63+
_accept = false
64+
}
65+
if _accept && strings.HasPrefix (_variable, "HYPERFINE_") {
66+
_accept = false
67+
}
68+
if !_accept {
69+
if _error := os.Unsetenv (_variable); _error != nil {
70+
panic (abortError (errorw (0x14024051, _error)))
71+
}
72+
}
73+
}
74+
75+
5576

5677

5778
if (len (os.Args) == 2) {

0 commit comments

Comments
 (0)