From 8caa56bf63a583995217e1fa1bfdb6be7b49d068 Mon Sep 17 00:00:00 2001 From: Jurgen Weber Date: Mon, 22 Jan 2018 14:57:24 +1100 Subject: [PATCH] try without testing the size, since in some OS's it is always returning 0 --- main.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 73b35b4..1e24ef2 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,12 @@ func failOnError(err error, msg string) { } } +func notApipe() { + fmt.Println("The command is intended to work with pipes.") + fmt.Println("Usage: echo mytext | stdin2rabbitmq") + os.Exit(1) +} + func read_in_stdin(debug bool) string { // massive copy and paste // https://flaviocopes.com/go-shell-pipes/ @@ -35,13 +41,11 @@ func read_in_stdin(debug bool) string { // if info.Mode()&os.ModeCharDevice != 0 || info.Size() <= 0 { // ModeCharDevice works on a console where you have a terminal - if (info.Mode()&os.ModeCharDevice == os.ModeCharDevice || info.Size() <= 0) { + if info.Mode()&os.ModeCharDevice == os.ModeCharDevice { // ModeNamedPipe is when you are ssh'd into something - if (info.Mode()&os.ModeNamedPipe == os.ModeNamedPipe || info.Size() <= 0) { - fmt.Println("The command is intended to work with pipes.") - fmt.Println("Usage: echo mytext | stdin2rabbitmq") - os.Exit(1) - } + //if (info.Mode()&os.ModeNamedPipe == os.ModeNamedPipe || info.Size() <= 0) { + notApipe() + //} } reader := bufio.NewReader(os.Stdin)