From 75eeb40f41f2839dc91281e24b1094180b97a8aa Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Wed, 29 Apr 2020 23:47:01 -0400 Subject: testv2: enable attach test testv2: enable attach test Signed-off-by: Qi Wang --- cmd/podman/containers/attach.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/podman/containers/attach.go b/cmd/podman/containers/attach.go index 78b52ad1b..ee4d811d7 100644 --- a/cmd/podman/containers/attach.go +++ b/cmd/podman/containers/attach.go @@ -71,11 +71,18 @@ func init() { } func attach(cmd *cobra.Command, args []string) error { + if len(args) > 1 || (len(args) == 0 && !attachOpts.Latest) { + return errors.Errorf("attach requires the name or id of one running container or the latest flag") + } + var name string + if len(args) > 0 { + name = args[0] + } attachOpts.Stdin = os.Stdin if attachOpts.NoStdin { attachOpts.Stdin = nil } attachOpts.Stdout = os.Stdout attachOpts.Stderr = os.Stderr - return registry.ContainerEngine().ContainerAttach(registry.GetContext(), args[0], attachOpts) + return registry.ContainerEngine().ContainerAttach(registry.GetContext(), name, attachOpts) } -- cgit v1.2.3-54-g00ecf