rust-cli / rust-cli/rexpect

Question: How pty behaives with empty command.

Open
#37 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
391
Forks
69
Avg merge
1d 34m
Merged PRs (30d)
2

Description

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));
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the test_no_cmd function and the PtyProcess::new(Command::new("")) call, then inspect the repository's pty/tty handling and terminal echo behavior. Done would be a clear explanation of why the echoed strings appear, including the effect of the empty command.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.