From f5a95fa244860bfa07f00f1c499446d24a60a697 Mon Sep 17 00:00:00 2001 From: Zhao Lei Date: Wed, 6 Jul 2016 11:46:22 +0800 Subject: [PATCH] cli: Workaround for ps's argument Currently, ps command can not support argument: (But following usage is in manual) | # ./runc ps 123 -ef | Incorrect Usage. | | NAME: | runc ps - ps displays the processes running inside a container | | USAGE: | runc ps [command options] [ps options] | | OPTIONS: | --format value, -f value select one of: table or json | | flag provided but not defined: -ef | # Instead of using odd command like: | # ./runc ps -- 123 -ef We can make it seems little better: | # ./runc ps 123 -- -ef | UID PID PPID C STIME TTY TIME CMD | root 29046 29038 0 11:18 pts/2 00:00:00 sh | # This patch also fixed manual which can not working in current code. Closes #788 Signed-off-by: Zhao Lei --- man/runc-ps.8.md | 2 +- ps.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/man/runc-ps.8.md b/man/runc-ps.8.md index 694990a90..d60634714 100644 --- a/man/runc-ps.8.md +++ b/man/runc-ps.8.md @@ -2,7 +2,7 @@ runc ps - ps displays the processes running inside a container # SYNOPSIS - runc ps [command options] [ps options] + runc ps [command options] [-- ps options] # OPTIONS --format value, -f value select one of: table(default) or json diff --git a/ps.go b/ps.go index 3b462a0a5..e40a973f2 100644 --- a/ps.go +++ b/ps.go @@ -16,7 +16,7 @@ import ( var psCommand = cli.Command{ Name: "ps", Usage: "ps displays the processes running inside a container", - ArgsUsage: ` [ps options]`, + ArgsUsage: ` [-- ps options]`, Flags: []cli.Flag{ cli.StringFlag{ Name: "format, f", @@ -43,6 +43,9 @@ var psCommand = cli.Command{ } psArgs := context.Args().Get(1) + if psArgs == "--" { + psArgs = context.Args().Get(2) + } if psArgs == "" { psArgs = "-ef" }