fn main() {
for l in std::io::stdin().lock().lines() { println!("{}", l.map(|s| s.escape_unicode())); }
}
As of rustc 0.13.0-nightly (126db549b 2014-12-15 00:07:35 +0000) this does not work: pressing Ctrl-Z then Return (a standard EOF sequence in Windows) simply prints Ok(\x1a\x0d\x0a), and pressing Ctrl-C immediately terminates the process while printing a panic! message.
This is apparently a regression of #3948. According to the relevant code from CPython, ReadConsoleW may return an error ERROR_OPERATION_ABORTED in both cases, and msvcrt (I think) will additionally issue a SIGINT for Ctrl-C within milliseconds. The current code handles none of them.
As of
rustc 0.13.0-nightly (126db549b 2014-12-15 00:07:35 +0000)this does not work: pressing Ctrl-Z then Return (a standard EOF sequence in Windows) simply printsOk(\x1a\x0d\x0a), and pressing Ctrl-C immediately terminates the process while printing apanic!message.This is apparently a regression of #3948. According to the relevant code from CPython,
ReadConsoleWmay return an errorERROR_OPERATION_ABORTEDin both cases, and msvcrt (I think) will additionally issue a SIGINT for Ctrl-C within milliseconds. The current code handles none of them.