Skip to content

Commit

Permalink
double tests?
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurgen Weber committed Jan 22, 2018
1 parent cbf1e31 commit 6f18f3e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ func read_in_stdin(debug bool) string {
}

// if info.Mode()&os.ModeCharDevice != 0 || info.Size() <= 0 {
if info.Mode()&os.ModeCharDevice == os.ModeCharDevice || info.Size() <= 0 {
fmt.Println("The command is intended to work with pipes.")
fmt.Println("Usage: echo mytext | stdin2rabbitmq")
os.Exit(1)
// ModeCharDevice works on a console where you have a terminal
if (info.Mode()&os.ModeCharDevice == os.ModeCharDevice || info.Size() <= 0) {
// 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)
}
}

reader := bufio.NewReader(os.Stdin)
Expand Down

0 comments on commit 6f18f3e

Please sign in to comment.