# Build your Own shell, The type builtin: executable files challenge

**URL:** <https://forum.codecrafters.io/t/build-your-own-shell-the-type-builtin-executable-files-challenge/10172>\
**Category:** Challenges\
**Tags:** challenge:shell\
**Created:** [May 8, 2025, 8:44am UTC](https://forum.codecrafters.io/t/build-your-own-shell-the-type-builtin-executable-files-challenge/10172 "2025-05-08T08:44:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MostafaEdrees11](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/mostafaedrees11/32/10669_2.png) [@MostafaEdrees11](https://forum.codecrafters.io/u/MostafaEdrees11)\
**Post date:** [May 8, 2025, 8:44am UTC](https://forum.codecrafters.io/t/build-your-own-shell-the-type-builtin-executable-files-challenge/10172/1 "2025-05-08T08:44:41Z")

</div>

I have a problem when I run `codecrafters test` I get this error

```auto
[tester::#MG5] Running tests for Stage #MG5 (The type builtin: executable files)
[tester::#MG5] [setup] export PATH=/tmp/bar:$PATH
[tester::#MG5] [setup] export PATH=/tmp/foo:$PATH
[tester::#MG5] [setup] Available executables:
[tester::#MG5] [setup] - my_exe
[tester::#MG5] Running ./your_program.sh
[tester::#MG5] Expected prompt ("$ ") but received ""
[tester::#MG5] Assertion failed.
[tester::#MG5] Test failed

```

and it’s working fine on my pc, i don’t know where is the problem and I print the prompt at the beginning of the code

```auto
  // extract environment paths
  char *fullPaths = getenv("PATH");
  pathCounter = extractPaths(fullPaths, environmentPaths);

  while(1) {
    // Uncomment this block to pass the first stage
    printf("$ ");

    // Wait for user input
    fgets(input, sizeof(input), stdin);
...

```

 ![PATH](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/9/92a106df5dacb30b9e603680d07d430cd93683d1.jpeg)

---

<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:** [May 8, 2025, 2:12pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-the-type-builtin-executable-files-challenge/10172/3 "2025-05-08T14:12:48Z")

</div>

Hey @MostafaEdrees11, 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:** ![MostafaEdrees11](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/mostafaedrees11/32/10669_2.png) [@MostafaEdrees11](https://forum.codecrafters.io/u/MostafaEdrees11)\
**Post date:** [May 8, 2025, 4:38pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-the-type-builtin-executable-files-challenge/10172/4 "2025-05-08T16:38:47Z")

</div>

Hey @andy1li  
This is the link for the repository

> **[GitHub - MostafaEdrees11/codecrafters-shell-c](https://github.com/MostafaEdrees11/codecrafters-shell-c)**
>
> Contribute to MostafaEdrees11/codecrafters-shell-c development by creating an account on GitHub.

---

<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:** [May 9, 2025, 1:06am UTC](https://forum.codecrafters.io/t/build-your-own-shell-the-type-builtin-executable-files-challenge/10172/6 "2025-05-09T01:06:46Z")

</div>

@MostafaEdrees11 I added a few logs:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/a/a4f2d976ef80297cae38f9e15e2483cbf2927d51.png)

Notice that the `after loop` flag is never printed:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/2/21d02f8f06a34e9e6702f7e73c1d582241bc529d.jpeg)

This means the code is stuck inside the loop and never exits.

Since the outer loop is straightforward enough, the issue must stem from the inner loop:

Turns out the inner loop needs an out-of-bounds check as well to avoid running indefinitely.

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/8/8483b8759dee6253b5cbd57cd6d3ad9c68205672.png)

Let me know if you’d like further clarification!

---

<div class="post-metadata">

**Author:** ![MostafaEdrees11](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/mostafaedrees11/32/10669_2.png) [@MostafaEdrees11](https://forum.codecrafters.io/u/MostafaEdrees11)\
**Post date:** [May 9, 2025, 7:30pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-the-type-builtin-executable-files-challenge/10172/8 "2025-05-09T19:30:16Z")

</div>

> [@andy1li](#):
>
> added a few logs

Thank you @andy1li very much ❤❤, It’s works  
The problem in the infinite loop as you mentioned

---

<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:** [May 14, 2025, 7:30pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-the-type-builtin-executable-files-challenge/10172/9 "2025-05-14T19:30:32Z")

</div>

Closed on May 14, 2025, 7:30pm UTC

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