template / commit
Fixed piping.
main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 2a8abd0..b9b5a03 100644 --- a/main.go +++ b/main.go @@ -326,13 +326,15 @@ func mainLogic(settings Settings) error { return fmt.Errorf("error finding profile: %v", err) } - var pipeInputScanner *bufio.Scanner = nil stat, err := os.Stdin.Stat() if err != nil { return fmt.Errorf("error getting stdin stat: %w", err) } - if stat.Size() > 0 { + var pipeInputScanner *bufio.Scanner = nil + incomingPipeData := (stat.Mode() & os.ModeCharDevice) == 0 + if incomingPipeData { pipeInputScanner = bufio.NewScanner(os.Stdin) + fmt.Printf("Reading from stdin\n") } // process profile