diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/containers/cp.go | 8 | ||||
-rw-r--r-- | cmd/podman/validate/args.go | 7 |
2 files changed, 14 insertions, 1 deletions
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go index 2c7d72b20..0ad258824 100644 --- a/cmd/podman/containers/cp.go +++ b/cmd/podman/containers/cp.go @@ -177,6 +177,10 @@ func copyFromContainer(container string, containerPath string, hostPath string) containerTarget = filepath.Dir(containerTarget) } + if !isStdout && containerInfo.IsDir && !hostInfo.IsDir { + return errors.New("destination must be a directory when copying a directory") + } + reader, writer := io.Pipe() hostCopy := func() error { defer reader.Close() @@ -334,6 +338,10 @@ func copyToContainer(container string, containerPath string, hostPath string) er stdinFile = tmpFile.Name() } + if hostInfo.IsDir && !containerInfo.IsDir { + return errors.New("destination must be a directory when copying a directory") + } + reader, writer := io.Pipe() hostCopy := func() error { defer writer.Close() diff --git a/cmd/podman/validate/args.go b/cmd/podman/validate/args.go index c00813369..fc07a6acc 100644 --- a/cmd/podman/validate/args.go +++ b/cmd/podman/validate/args.go @@ -3,6 +3,7 @@ package validate import ( "fmt" "strconv" + "strings" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/pkg/errors" @@ -20,7 +21,11 @@ func NoArgs(cmd *cobra.Command, args []string) error { // SubCommandExists returns an error if no sub command is provided func SubCommandExists(cmd *cobra.Command, args []string) error { if len(args) > 0 { - return errors.Errorf("unrecognized command `%[1]s %[2]s`\nTry '%[1]s --help' for more information.", cmd.CommandPath(), args[0]) + suggestions := cmd.SuggestionsFor(args[0]) + if len(suggestions) == 0 { + return errors.Errorf("unrecognized command `%[1]s %[2]s`\nTry '%[1]s --help' for more information.", cmd.CommandPath(), args[0]) + } + return errors.Errorf("unrecognized command `%[1]s %[2]s`\n\nDid you mean this?\n\t%[3]s\n\nTry '%[1]s --help' for more information.", cmd.CommandPath(), args[0], strings.Join(suggestions, "\n\t")) } return errors.Errorf("missing command '%[1]s COMMAND'\nTry '%[1]s --help' for more information.", cmd.CommandPath()) } |