Extra 'j' appended stdin but not really present

I’m stuck on Stage #EI0

This stemmed from #RH7. I tried pwd just to verify

Here are my logs:

remote: [tester::#EI0] Running tests for Stage #EI0 (Navigation - The pwd builtin)
remote: [tester::#EI0] Running ./your_program.sh
remote: [your-program] $ type pwdj
remote: [tester::#EI0] ^ Line does not match expected value.
remote: [tester::#EI0] Expected: "$ type pwd"
remote: [tester::#EI0] Received: "$ type pwdj"
remote: [tester::#EI0] Assertion failed.
remote: [tester::#EI0] Test failed

And here’s a snippet of my relevant code when I press enter.

I have no idea from where the extra ‘j’ is coming from.

This runs perfectly fine locally.

I am using Crossterm and here’s my complete solution: GitHub - sandipndev-space/shell-rust

                KeyCode::Enter => {
                    print!("\r\n");
                    io::stdout().flush()?;

                    let shell_line = line.trim_end();
                    if !shell_line.is_empty() {
                        history::add_entry(shell_line.to_string());
                        run_shell_line(shell_line)?;
                    }

                    line.clear();

                    // Drain any pending input bytes
                    while event::poll(std::time::Duration::from_millis(0))? {
                        if let Event::Key(_) = event::read()? {}
                    }

                    print_prompt(&mut stdout, &line)?;
                }

I FIXED IT MYSELF

Apparently the tester uses Control + J instead of Enter to test.

Codecrafters should add this to docs.

1 Like

Hey @sandipndev, looks like crossterm maps newline (0xA) to Ctrl+J in raw mode:

1 Like

Ohhh than’s a great find. Thanks - it was me who complected it that means!

1 Like