rexpect icon indicating copy to clipboard operation
rexpect copied to clipboard

Question: How pty behaives with empty command.

Open zhiburt opened this issue 4 years ago • 0 comments

I was tinkering pty/tty stuff and still not clearly understand how it works :). And you're @philippkeller the most right person who I could address this question. Example below.

Currently this test will pass. But why?

Why we get this echoed strings?

I've tested the flags.local_flags &= !termios::LocalFlags::ECHO works fine.

Thanks in advance.


    #[test]
    /// Open cat, write string, read back string twice, send Ctrl^C and check that cat exited
    fn test_no_cmd() {
        // wrapping into closure so I can use ?
        || -> std::io::Result<()> {
            let process = PtyProcess::new(Command::new("")).expect("could not execute cat");
            let f = process.get_file_handle();
            let mut writer = LineWriter::new(&f);
            let mut reader = BufReader::new(&f);
            writer.write_all(b"hello cat\n")?;
            let mut buf = String::new();
            reader.read_line(&mut buf)?;
            assert_eq!(buf, "hello cat\r\n");

            Ok(())
        }()
        .unwrap_or_else(|e| panic!("test_cat failed: {}", e));
    }

zhiburt avatar Jun 25 '21 14:06 zhiburt