helper/bwrap: sort SetEnv arguments

This guarantees consistency of resulting args.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
Ophestra Umiker 2024-10-15 02:55:48 +09:00
parent aa5dd2313c
commit 3015266e5a
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
1 changed files with 12 additions and 3 deletions

View File

@ -1,5 +1,9 @@
package bwrap package bwrap
import (
"slices"
)
const ( const (
SetEnv = iota SetEnv = iota
@ -28,9 +32,14 @@ var pairArgs = [...]string{
func (c *Config) pairArgs() Builder { func (c *Config) pairArgs() Builder {
var n pairArg var n pairArg
n[SetEnv] = make([][2]string, 0, len(c.SetEnv)) n[SetEnv] = make([][2]string, len(c.SetEnv))
for k, v := range c.SetEnv { keys := make([]string, 0, len(c.SetEnv))
n[SetEnv] = append(n[SetEnv], [2]string{k, v}) for k := range c.SetEnv {
keys = append(keys, k)
}
slices.Sort(keys)
for i, k := range keys {
n[SetEnv][i] = [2]string{k, c.SetEnv[k]}
} }
// Arg types: // Arg types: