Skip to content

Commit 8caa56b

Browse files
author
Jurgen Weber
committed
try without testing the size, since in some OS's it is always returning 0
1 parent 6f18f3e commit 8caa56b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

main.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ func failOnError(err error, msg string) {
2020
}
2121
}
2222

23+
func notApipe() {
24+
fmt.Println("The command is intended to work with pipes.")
25+
fmt.Println("Usage: echo mytext | stdin2rabbitmq")
26+
os.Exit(1)
27+
}
28+
2329
func read_in_stdin(debug bool) string {
2430
// massive copy and paste
2531
// https://flaviocopes.com/go-shell-pipes/
@@ -35,13 +41,11 @@ func read_in_stdin(debug bool) string {
3541

3642
// if info.Mode()&os.ModeCharDevice != 0 || info.Size() <= 0 {
3743
// ModeCharDevice works on a console where you have a terminal
38-
if (info.Mode()&os.ModeCharDevice == os.ModeCharDevice || info.Size() <= 0) {
44+
if info.Mode()&os.ModeCharDevice == os.ModeCharDevice {
3945
// 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-
}
46+
//if (info.Mode()&os.ModeNamedPipe == os.ModeNamedPipe || info.Size() <= 0) {
47+
notApipe()
48+
//}
4549
}
4650

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

0 commit comments

Comments
 (0)