From 27046a9e06de44ecc4b1662ca43977cc2d6c789e Mon Sep 17 00:00:00 2001 From: Daniel Canter Date: Thu, 2 Sep 2021 03:59:56 -0700 Subject: [PATCH] Fix cwd flag for `ctr tasks exec` It seems like the cwd flag isn't used anywhere for ctr tasks exec. This change just sets the cwd field on the spec for the execed process if a new one was asked for, otherwise it will continue using whatever was on the containers spec. Signed-off-by: Daniel Canter --- cmd/ctr/commands/tasks/exec.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/ctr/commands/tasks/exec.go b/cmd/ctr/commands/tasks/exec.go index c1a4b8bbd..f31a13f00 100644 --- a/cmd/ctr/commands/tasks/exec.go +++ b/cmd/ctr/commands/tasks/exec.go @@ -104,6 +104,10 @@ var execCommand = cli.Command{ pspec.Terminal = tty pspec.Args = args + if cwd := context.String("cwd"); cwd != "" { + pspec.Cwd = cwd + } + task, err := container.Task(ctx, nil) if err != nil { return err