Stuck on Stage #QP2

I’m stuck on Stage #QP2. Even though I managed to pass the test cases for this particular stage, the tests for the previous stage(specifically #CZ2) won’t pass. Here is the output:

[tester::#OO8] Running tests for Stage #OO8 (Print a prompt)
[tester::#OO8] Running ./your_program.sh
[your-program] $ 
[tester::#OO8] ✓ Received prompt
[tester::#OO8] Test passed.

[tester::#CZ2] Running tests for Stage #CZ2 (Handle invalid commands)
[tester::#CZ2] Running ./your_program.sh
[your-program] $ invalid_orange_command
[your-program]                         
[tester::#CZ2] Output does not match expected value.
[tester::#CZ2] Expected: "invalid_orange_command: command not found"
[tester::#CZ2] Received: "                        "
[tester::#CZ2] Assertion failed.
[tester::#CZ2] Test failed

But when I test it on my own it clearly works:

$ invalid_orange_command
invalid_orange_command: command not found
$ 

Here is the link to my code: GitHub - danilovict2/go-shell

I’ll take a look and try to get back to you by early next week.

Hi @danilovict2, the immediate bug is here:

Every command sent to your shell ends with a line feed (\n) instead of a carriage return and line feed (\r\n).

Okay, but how do I fix it. I already tried replacing it with ‘\n’ and it doesn’t work for me

Would you mind trying again? Replacing it with \n should at least help you pass #CZ2 (Handle invalid commands).

Sure, there are other issues breaking other stages, but they are not related to \r here.

It may pass the stage, but when I run the program on my computer it doesn’t work. It has some really weird behaviour. When I press enter, it just moves the cursor to the begging of the line and the only thing you can do is exit the program with ctrl+c

@danilovict2 could you let me know which system you’re using?

I just ran your code on my Mac, and the behavior is indeed unexpected. I’ll need to investigate further.

I’ve figured it out. I just moved the term code in the parser.

1 Like

Feel free to share an overview of your changes. It could help others who encounter the same issue.

In my switch, I replaced

case '\r'

with

case '\r', '\n'

And I’ve moved term.MakeRaw to the function that parses the input, so that it doesn’t affect the whole program, just that function

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.