Skip to content

Commit 6f18f3e

Browse files
author
Jurgen Weber
committed
double tests?
1 parent cbf1e31 commit 6f18f3e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

main.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ func read_in_stdin(debug bool) string {
3434
}
3535

3636
// if info.Mode()&os.ModeCharDevice != 0 || info.Size() <= 0 {
37-
if info.Mode()&os.ModeCharDevice == os.ModeCharDevice || info.Size() <= 0 {
38-
fmt.Println("The command is intended to work with pipes.")
39-
fmt.Println("Usage: echo mytext | stdin2rabbitmq")
40-
os.Exit(1)
37+
// ModeCharDevice works on a console where you have a terminal
38+
if (info.Mode()&os.ModeCharDevice == os.ModeCharDevice || info.Size() <= 0) {
39+
// ModeNamedPipe is when you are ssh'd into something
40+
if (info.Mode()&os.ModeNamedPipe == os.ModeNamedPipe || info.Size() <= 0) {
41+
fmt.Println("The command is intended to work with pipes.")
42+
fmt.Println("Usage: echo mytext | stdin2rabbitmq")
43+
os.Exit(1)
44+
}
4145
}
4246

4347
reader := bufio.NewReader(os.Stdin)

0 commit comments

Comments
 (0)