Skip to content

Commit

Permalink
copy: remove size check for reading from stdin
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tjhop committed May 7, 2019
1 parent 4c1d3b9 commit 1e2cdc0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1e2cdc0

Please sign in to comment.