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

**URL:** <https://forum.codecrafters.io/t/repl-shell-tried-two-different-codes-worked-the-first-time-not-working-after-another-push/4592>\
**Category:** Challenges\
**Tags:** challenge:shell\
**Created:** [February 1, 2025, 5:16pm UTC](https://forum.codecrafters.io/t/repl-shell-tried-two-different-codes-worked-the-first-time-not-working-after-another-push/4592 "2025-02-01T17:16:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DiegoFilippoMarino](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/diegofilippomarino/32/4675_2.png) [@DiegoFilippoMarino](https://forum.codecrafters.io/u/DiegoFilippoMarino)\
**Post date:** [February 1, 2025, 5:16pm UTC](https://forum.codecrafters.io/t/repl-shell-tried-two-different-codes-worked-the-first-time-not-working-after-another-push/4592/1 "2025-02-01T17:16:23Z")

</div>

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:

```auto
[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:

```python
import sys
def main():

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

if __name__ == " __main__":
    main()

```

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [February 1, 2025, 5:16pm UTC](https://forum.codecrafters.io/t/repl-shell-tried-two-different-codes-worked-the-first-time-not-working-after-another-push/4592/2 "2025-02-01T17:16:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [February 7, 2025, 10:09pm UTC](https://forum.codecrafters.io/t/repl-shell-tried-two-different-codes-worked-the-first-time-not-working-after-another-push/4592/4 "2025-02-07T22:09:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![homocodian](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/homocodian/32/5055_2.png) [@homocodian](https://forum.codecrafters.io/u/homocodian)\
**Post date:** [February 16, 2025, 10:46pm UTC](https://forum.codecrafters.io/t/repl-shell-tried-two-different-codes-worked-the-first-time-not-working-after-another-push/4592/6 "2025-02-16T22:46:49Z")

</div>

I’m getting same error

```c++

    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

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [February 17, 2025, 3:23am UTC](https://forum.codecrafters.io/t/repl-shell-tried-two-different-codes-worked-the-first-time-not-working-after-another-push/4592/7 "2025-02-17T03:23:00Z")

</div>

Hi @homocodian, could you [upload your code to GitHub](https://docs.codecrafters.io/features/publish-to-github) and share the link? It will be much easier to debug if I can run it directly.

---

<div class="post-metadata">

**Author:** ![homocodian](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/homocodian/32/5055_2.png) [@homocodian](https://forum.codecrafters.io/u/homocodian)\
**Post date:** [February 17, 2025, 1:54pm UTC](https://forum.codecrafters.io/t/repl-shell-tried-two-different-codes-worked-the-first-time-not-working-after-another-push/4592/10 "2025-02-17T13:54:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [March 10, 2025, 9:44am UTC](https://forum.codecrafters.io/t/repl-shell-tried-two-different-codes-worked-the-first-time-not-working-after-another-push/4592/12 "2025-03-10T09:44:12Z")

</div>

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