REPL shell: tried two different codes, worked the first time, not working after another push

I’m stuck on Stage #PN5.

I’ve tried both a while True into break, and a main().
It worked the first time, but after i tried changing the code a bit, it is not passing the tests now.

Here are my logs:

[tester::#PN5] Running tests for Stage #PN5 (The exit builtin)
[tester::#PN5] Running ./your_program.sh
[your-program] $ invalid_pineapple_command
[your-program] invalid_pineapple_command: command not found
[tester::#PN5] ✓ Received command not found message
[your-program] $ exit 0
[tester::#PN5] Error reading output: condition not met
[tester::#PN5] Test failed

And here’s a snippet of my code:

import sys
def main():

    sys.stdout.write("$ ")
    command = input() #try2
    print(f"{command}: command not found")
    main()

if __name__ == "__main__":
    main()

Hi, thanks for your post!

I’m currently out of the office and will return on Feb 3. I’ll get back to you as soon as possible after I’m back.

Hi @DiegoFilippoMarino, looks like you’ve got past this stage. Do you happen to remember what was wrong? Would love to see if we can improve the tester / instructions.

I’m getting same error


    input = utils::trim(input);

    if (input == "exit") {
      exit(EXIT_SUCCESS);
    }

    const std::vector<std::string> tokens = utils::split(input, ' ');
    size_t tokens_size = tokens.size();

    if (tokens[0] == "exit" && tokens.size() == 2 &&
        utils::isNumber(tokens[1])) {
      exit(std::stoi(tokens[1]));
    }

[tester::#PN5] Running tests for Stage #PN5 (The exit builtin)
[tester::#PN5] Running ./your_program.sh
[your-program] $ invalid_raspberry_command
[your-program] invalid_raspberry_command: command not found
[tester::#PN5] ✓ Received command not found message
[your-program] $ exit 0
[tester::#PN5] Error reading output: condition not met
[tester::#PN5] Test failed

Hi @homocodian, could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.

Sorry, it was my mistake; my child process was not terminating when an invalid command was executed.

1 Like

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