fix(tools): inject TZ env into shell commands from config timezone
Ensure shell scripts executed via the exec tool use the same timezone as the Go process (configured via agents.defaults.timezone). Without this, shell date commands use the OS timezone, causing mismatch when the config timezone differs from the system timezone.
This commit is contained in:
parent
ff6c412882
commit
0870815af2
1 changed files with 7 additions and 0 deletions
|
|
@ -185,6 +185,13 @@ func (t *ExecTool) Execute(ctx context.Context, args map[string]any) *ToolResult
|
||||||
cmd.Dir = cwd
|
cmd.Dir = cwd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inherit parent env and inject TZ from config timezone (time.Local).
|
||||||
|
// This ensures shell scripts use the same timezone as the Go process.
|
||||||
|
cmd.Env = os.Environ()
|
||||||
|
if tz := time.Local.String(); tz != "Local" && tz != "" {
|
||||||
|
cmd.Env = append(cmd.Env, "TZ="+tz)
|
||||||
|
}
|
||||||
|
|
||||||
prepareCommandForTermination(cmd)
|
prepareCommandForTermination(cmd)
|
||||||
|
|
||||||
var stdout, stderr bytes.Buffer
|
var stdout, stderr bytes.Buffer
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue