readline icon indicating copy to clipboard operation
readline copied to clipboard

Fails to read piped stdin in windows

Open YairHalberstadt opened this issue 1 year ago • 0 comments

When piping stdin from another process on windows, readline fails to read the piped stdin.

Say my binary does this:

func main() {
	rl, err := NewEx(&Config{})
	if err != nil {
		fmt.Println(err)
		return
	}
	line, err := rl.Readline()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(line)
}

And then I use it as follows

echo "hello world" | MyBinary.exe

fails with EOF instead of printing hello world.

On linux this works as expected.

The issue appears to be in rawreader_windows.go where the call to ReadConsoleInputW returns "invalid function".

YairHalberstadt avatar Jul 26 '23 14:07 YairHalberstadt