From 5ed828f26a59450a62c331044fed7c03333d0f9e Mon Sep 17 00:00:00 2001 From: "Anand Babu (AB) Periasamy" Date: Wed, 3 Jun 2015 19:48:09 -0700 Subject: [PATCH] handle broken pipe for cat --- cmd-cat.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd-cat.go b/cmd-cat.go index 84d247af..4aa6cefc 100644 --- a/cmd-cat.go +++ b/cmd-cat.go @@ -21,6 +21,7 @@ import ( "fmt" "io" "os" + "syscall" "github.com/minio/cli" "github.com/minio/mc/pkg/console" @@ -120,7 +121,11 @@ func doCatCmd(sourceURLConfigMap map[string]*hostConfig) (string, error) { if err != nil { switch e := iodine.ToError(err).(type) { case *os.PathError: - return "Reading data to stdout failed, unexpected problem.. please report this error", iodine.New(e, nil) + if e.Err == syscall.EPIPE { + // stdout closed by the user. Gracefully exit. + return "", nil + } + return "Writing data to stdout failed, unexpected problem.. please report this error", iodine.New(e, nil) default: return "Reading data from source failed: " + url, iodine.New(errors.New("Copy data from source failed"), nil) }