copyto; abort when there is no stdin (#379)

This commit is contained in:
Michael Quigley 2023-07-27 17:00:05 -04:00
parent 33a8088377
commit c43f34083d
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -16,10 +16,15 @@ const MAX_PASTE_SIZE = 64 * 1024
var data []byte
func main() {
var err error
data, err = io.ReadAll(os.Stdin)
if err != nil {
panic(err)
stat, _ := os.Stdin.Stat()
if stat.Mode()&os.ModeCharDevice == 0 {
var err error
data, err = io.ReadAll(os.Stdin)
if err != nil {
panic(err)
}
} else {
panic("usage: 'copyto' is requires input from stdin; pipe your paste buffer into it")
}
root, err := environment.LoadRoot()