summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortheimpostor <sahirhoda@gmail.com>2024-08-18 11:42:40 -0500
committertheimpostor <sahirhoda@gmail.com>2024-08-18 11:42:40 -0500
commit2a3415446574c63d7912c2be2f7493eb369435a4 (patch)
tree80e9b865b4ad66069d4ea7aae25275c9923b304f
parentfab63c18bbc165565013c1bfdcd61692b9745597 (diff)
check stdin readable
-rw-r--r--main.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/main.go b/main.go
index 29e2c35..a3b759a 100644
--- a/main.go
+++ b/main.go
@@ -13,6 +13,7 @@ import (
"github.com/gdamore/tcell/v2"
"github.com/jba/slog/handlers/loghandler"
+ "github.com/mattn/go-isatty"
"runtime/debug"
@@ -114,6 +115,10 @@ func identifyTerm() {
func copy(fnames []string) error {
// copy
if len(fnames) == 0 {
+ if isatty.IsTerminal(os.Stdin.Fd()) || isatty.IsCygwinTerminal(os.Stdin.Fd()) {
+ return fmt.Errorf("nothing on stdin")
+ }
+
fnames = []string{"-"}
} else {
for _, fname := range fnames {