Stuck at a problem in build your own shell

I’m stuck on Stage #(change to your stage, ex. #JM3).

I’ve tried THE CODE IN THE CODE EXAMPLE GIVEN still its not working

Here are my logs:

[tester::#MG5] Running ./your_program.sh
[your-program] $ type cat
[your-program] cat: not found
[tester::#MG5] ^ Line does not match expected value.
[tester::#MG5] Expected: "cat is /bin/cat"
[tester::#MG5] Received: "cat: not found"
[your-program] $ 
[tester::#MG5] Test failed

And here’s a snippet of my code:

import sys
import shutil

builtin_commands = ["echo", "exit", "type"]


def main():
    while True:
        sys.stdout.write("$ ")
        command = input()
        if command.startswith("exit"):
            break
        elif command.startswith("echo"):
            print(command[5:])
        elif command.startswith("type"):
            if command[5:] in builtin_commands:
                print(f"{command[5:]} is a shell builtin")
            elif path := shutil.which(command[5:]):
                print(f"{command[5:]} is {path}")
            else:
                print(f"{command[5:]}: not found")
        else:
            print(f"{command}: command not found")


if __name__ == "__main__":
    main()

never mind , solved the issue

1 Like

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