Skip to content

Commit

Permalink
try without testing the size, since in some OS's it is always returni…
Browse files Browse the repository at this point in the history
…ng 0
  • Loading branch information
Jurgen Weber committed Jan 22, 2018
1 parent 6f18f3e commit 8caa56b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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)
Expand Down

0 comments on commit 8caa56b

Please sign in to comment.