From a4674e2601117e97879b7e77c7a30026651f8fb9 Mon Sep 17 00:00:00 2001 From: Zeming Lin Date: Wed, 3 May 2023 14:16:47 -0700 Subject: [PATCH] Fix bug for when no input is piped but -q is used --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 8638311..fd0c0d0 100644 --- a/main.go +++ b/main.go @@ -168,7 +168,9 @@ func main() { // no args, or interactive... read from stdin // this is mainly for replacing text in vim - if len(args) == 0 && !PromptMode { + fi, _ := os.Stdin.Stat() + inputIsFromPipe = (fi.Mode() & os.ModeCharDevice) == 0 + if len(args) == 0 && !PromptMode && inputIsFromPipe { reader := bufio.NewReader(os.Stdin) var buf bytes.Buffer for {