From 9f884edbbf99c316f7954aa021972da1148031d5 Mon Sep 17 00:00:00 2001 From: Kohei Tokunaga Date: Thu, 27 Apr 2023 11:14:51 +0900 Subject: [PATCH] monitor: use shlex Signed-off-by: Kohei Tokunaga --- monitor/monitor.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/monitor/monitor.go b/monitor/monitor.go index 8008c089..2e00c8b4 100644 --- a/monitor/monitor.go +++ b/monitor/monitor.go @@ -5,7 +5,6 @@ import ( "fmt" "io" "sort" - "strings" "sync" "sync/atomic" "text/tabwriter" @@ -17,6 +16,7 @@ import ( "github.com/docker/buildx/monitor/types" "github.com/docker/buildx/util/ioset" "github.com/docker/buildx/util/progress" + "github.com/google/shlex" "github.com/moby/buildkit/client" "github.com/moby/buildkit/identity" "github.com/pkg/errors" @@ -125,8 +125,11 @@ func RunMonitor(ctx context.Context, curRef string, options *controllerapi.Build } return } - args := strings.Fields(l) // TODO: use shlex - if len(args) == 0 { + args, err := shlex.Split(l) + if err != nil { + fmt.Fprintf(stdout, "monitor: failed to parse command: %v", err) + continue + } else if len(args) == 0 { continue }