From 1e2cdc0fefac9efa7b357b0a84510179e16b963d Mon Sep 17 00:00:00 2001 From: TJ Hoplock Date: Tue, 7 May 2019 18:50:10 -0400 Subject: [PATCH] copy: remove size check for reading from stdin Turns out this causes issues with commands that need to retreive data and/or do not output their results immediately, ie: ``` curl -4sL echo.tjhop.io | clip copy ``` would error out because `curl` hadn't gotten the data yet. This didn't come up in testing, since I was invoking the binary with `go run main.go copy` which takes a second or so to initialize things. Realistically, I can't think of a _bad_ thing that'd really happen with not checking the input size. If it's empty, it'll just clear out the clipboard, which is sane to me. --- cmd/copy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/copy.go b/cmd/copy.go index 2ba2140..b6b979f 100644 --- a/cmd/copy.go +++ b/cmd/copy.go @@ -85,7 +85,7 @@ func writeStdinToClipboard() error { panic(err) } - if info.Mode()&os.ModeCharDevice == os.ModeCharDevice || info.Size() <= 0 { + if info.Mode()&os.ModeCharDevice == os.ModeCharDevice { fmt.Println("Invalid input device for stdin") } else { scanner := bufio.NewScanner(os.Stdin)