From a998e92a51d5de734357b9bc0a8de1e504ada809 Mon Sep 17 00:00:00 2001 From: Christopher Obbard Date: Tue, 15 Aug 2023 11:17:02 +0100 Subject: [PATCH] commands: Allow working directory to be set when not running in chroot Currently Command.Dir is unsed; hook it up such that when commands are not running in a chroot, the working directory can be set. Signed-off-by: Christopher Obbard --- commands.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/commands.go b/commands.go index c8430fb0..8d83a117 100644 --- a/commands.go +++ b/commands.go @@ -253,6 +253,11 @@ func (cmd Command) Run(label string, cmdline ...string) error { exe.Env = append(os.Environ(), cmd.extraEnv...) } + // Allow working directory to be set for commands not running in chroot + if len(cmd.Dir) > 0 && cmd.ChrootMethod == CHROOT_METHOD_NONE { + exe.Dir = cmd.Dir + } + // Disable services start/stop for commands running in chroot if cmd.ChrootMethod != CHROOT_METHOD_NONE { services := ServiceHelper{cmd.Chroot}