From c562e4cd91f528582d1ba898625d531a587dfcdd Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Sat, 11 Jun 2016 17:46:47 -0400 Subject: [PATCH] exec: Support command arguments This enables support for exec command argument starting with a '-'. This uses the usual argument separator '--', for example: runc exec containerid -- ps -afx Without this, cli interprets command argument and fails with 'flag provided but not defined'. Signed-off-by: Tristan Cacqueray --- exec.go | 5 ++++- man/runc-exec.8.md | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/exec.go b/exec.go index f3a22e09..62a4c527 100644 --- a/exec.go +++ b/exec.go @@ -17,7 +17,7 @@ import ( var execCommand = cli.Command{ Name: "exec", Usage: "execute new process inside the container", - ArgsUsage: ` + ArgsUsage: ` -- [command options] Where "" is the name for the instance of the container and "" is the command to be executed in the container. @@ -149,6 +149,9 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) { } p := spec.Process p.Args = context.Args()[1:] + if len(p.Args) > 1 && p.Args[0] == "--" { + p.Args = p.Args[1:] + } // override the cwd, if passed if context.String("cwd") != "" { p.Cwd = context.String("cwd") diff --git a/man/runc-exec.8.md b/man/runc-exec.8.md index a1f8a333..e47f8284 100644 --- a/man/runc-exec.8.md +++ b/man/runc-exec.8.md @@ -2,7 +2,7 @@ runc exec - execute new process inside the container # SYNOPSIS - runc exec [command options] + runc exec [command options] -- [args...] Where "" is the name for the instance of the container and "" is the command to be executed in the container.