diff options
| author | theimpostor <sahirhoda@gmail.com> | 2024-08-18 11:42:40 -0500 |
|---|---|---|
| committer | theimpostor <sahirhoda@gmail.com> | 2024-08-18 11:42:40 -0500 |
| commit | 2a3415446574c63d7912c2be2f7493eb369435a4 (patch) | |
| tree | 80e9b865b4ad66069d4ea7aae25275c9923b304f | |
| parent | fab63c18bbc165565013c1bfdcd61692b9745597 (diff) | |
check stdin readable
| -rw-r--r-- | main.go | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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 { |
