Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interact method on spawn_bash session doesn't echoes input #10

Open
zhiburt opened this issue Jul 30, 2021 · 7 comments
Open

interact method on spawn_bash session doesn't echoes input #10

zhiburt opened this issue Jul 30, 2021 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@zhiburt
Copy link
Owner

zhiburt commented Jul 30, 2021

My guess for some reason when we do an expect of initial prompt something is changed so type ENTER
causes a production of CTRL-M(^M) where without it it causes \r\n

@zhiburt
Copy link
Owner Author

zhiburt commented Jul 30, 2021

related: #3

@zhiburt
Copy link
Owner Author

zhiburt commented Aug 3, 2021

A research showed - reading changes a terminal line settings:

Here use cargo run --example interact and type stty command.

With read before interact
stty^Mspeed 38400 baud; line = 0;
-brkint -imaxbel
-echo
Without presiding read
EXPECT_PROMPT>stty
speed 38400 baud; line = 0;
-brkint -imaxbel

@zhiburt
Copy link
Owner Author

zhiburt commented Aug 3, 2021

Here's a termios flags differences

Termios { inner: RefCell { value: termios { c_iflag: 1024, c_oflag: 5, c_cflag: 191, c_lflag: 35385, c_line: 0, c_cc: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], c_ispeed: 15, c_ospeed: 15 } }, input_flags: IXON, output_flags: OPOST | ONLCR, control_flags: CS6 | CS7 | CS8 | CREAD | CSIZE, local_flags: ECHOKE | ECHOE | ECHOK | ECHO | ECHOCTL | ISIG | IEXTEN, control_chars: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Termios { inner: RefCell { value: termios { c_iflag: 1024, c_oflag: 5, c_cflag: 191, c_lflag: 35377, c_line: 0, c_cc: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], c_ispeed: 15, c_ospeed: 15 } }, input_flags: IXON, output_flags: OPOST | ONLCR, control_flags: CS6 | CS7 | CS8 | CREAD | CSIZE, local_flags: ECHOKE | ECHOE | ECHOK | ECHOCTL | ISIG | IEXTEN, control_chars: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }

@zhiburt
Copy link
Owner Author

zhiburt commented Aug 3, 2021

@zhiburt zhiburt added the help wanted Extra attention is needed label Aug 3, 2021
@zhiburt
Copy link
Owner Author

zhiburt commented Aug 9, 2021

There was an idea that it may be an issue of spawned program. As it may change termios settings at any point.
And it may be true.

Spawning cat doesn't have such an issue wherewith python && bash there are.

Code which reproduces an issue

fn main() {
    use expectrl::Session;

    let mut bash = Session::spawn("python").expect("Error while spawning bash");

    bash.expect(">>> ").unwrap();

    let status = bash.interact().expect("Failed to start interact");

    println!("Quiting status {:?}", status);
}

@zhiburt
Copy link
Owner Author

zhiburt commented Aug 10, 2021

If we would read only preamble but don't >>> chars everything but be fine.

So the actual issue is in reading exactly PROMPT.

Why?

@zhiburt
Copy link
Owner Author

zhiburt commented Sep 17, 2021

It seems like bash cab override tty mode at any time.

I am trying to create a powershell repl and pwsh behaives completely differently.

Here I am typing a random chars pimode and an each input pwsh seems to clear old one.

PS /home/mzhiburt/projects/expectrl> 
INPUT "p"                                              
OUTPUT "p"                                                       
pINPUT "i"                                                                  
OUTPUT "\u{1b}[12;38H"                    
OUTPUT "pi"   
piINPUT "m"             
OUTPUT "\u{1b}[12;38Hpim"               
pimINPUT "o" 
OUTPUT "\u{1b}[12;38Hpimo"             
pimoINPUT "d"
OUTPUT "\u{1b}[12;38Hpimod"           
pimodINPUT "e"           
OUTPUT "\u{1b}[12;38H"       
OUTPUT "pimode"                       
pimodeINPUT "\r"                                             
OUTPUT "\r\n"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant