chzyer / readline

Readline is a pure go(golang) implementation for GNU-Readline kind library
MIT License
2.1k stars 280 forks source link

Fails to read piped stdin in windows #229

Open YairHalberstadt opened 1 year ago

YairHalberstadt commented 1 year ago

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".