diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2023-02-16 18:01:43 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2023-02-18 07:45:54 +0100 |
| commit | d8336833514c8d2fd456ad000c2ab83450e2e78a (patch) | |
| tree | 0de71ebcd9bfa0eb92b835575516ff9405e1f7c5 /tools | |
| parent | d02e9a70103778b8294e3f045d635acfd005a534 (diff) | |
tools/syz-kconf: support env variables in shell commands
Required for ChromeOS update.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/syz-kconf/kconf.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/syz-kconf/kconf.go b/tools/syz-kconf/kconf.go index 2bf66532c..0d8c48ac2 100644 --- a/tools/syz-kconf/kconf.go +++ b/tools/syz-kconf/kconf.go @@ -239,6 +239,7 @@ func (ctx *Context) generate() error { } func (ctx *Context) executeShell() error { + envRe := regexp.MustCompile("^[A-Z0-9_]+=") for _, shell := range ctx.Inst.Shell { if !ctx.Inst.Features.Match(shell.Constraints) { continue @@ -253,7 +254,18 @@ func (ctx *Context) executeShell() error { } continue } - if _, err := osutil.RunCmd(10*time.Minute, ctx.SourceDir, args[0], args[1:]...); err != nil { + env := os.Environ() + for len(args) > 1 { + if !envRe.MatchString(args[0]) { + break + } + env = append(env, args[0]) + args = args[1:] + } + cmd := osutil.Command(args[0], args[1:]...) + cmd.Dir = ctx.SourceDir + cmd.Env = env + if _, err := osutil.Run(10*time.Minute, cmd); err != nil { return err } } |
