I ran the test cases and I get
remote: [tester::#MG5] Running tests for Stage #MG5 (The type builtin: executable files)
remote: [tester::#MG5] [setup] export PATH=/tmp/foo:$PATH
remote: [tester::#MG5] [setup] export PATH=/tmp/baz:$PATH
remote: [tester::#MG5] [setup] Available executables:
remote: [tester::#MG5] [setup] - my_exe
remote: [tester::#MG5] Running ./your_program.sh
remote: [your-program] $ type cat
remote: [your-program] cat: not found
remote: [tester::#MG5] Output does not match expected value.
remote: [tester::#MG5] Expected: "cat is /bin/cat"
remote: [tester::#MG5] Received: "cat: not found"
remote: [your-program] $
remote: [tester::#MG5] Assertion failed.
remote: [tester::#MG5] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
remote:
remote: Try our CLI to run tests faster without Git: https://codecrafters.io/cli
remote:
remote: View our article on debugging test failures: https://codecrafters.io/debug
but when I try it I get
$ type cat
cat is /usr/bin/cat
$
here’s a snippet of my code:
import sys
import shutil
PATH = shutil.which
def type_cmd(args):
for i in range(len(args)):
if args[i] in builtin_commands:
print(f"{args[i]} is a shell builtin")
elif PATH(args[i]):
print(f"{args[i]} is {PATH(args[i])}")
else:
print(f"{args[i]}: not found")
builtin_commands = {"type": type_cmd,
"echo": lambda args: sys.stdout.write(" ".join(args) + "\n"),
"exit": lambda args: sys.exit(0),}
def main():
# Uncomment this block to pass the first stage
sys.stdout.write("$ ")
# Wait for user input
command = input()
if command:
cmd, *args = command.split()
if cmd in builtin_commands:
builtin_commands[cmd](args)
else:
print(f"{cmd}: not found")
main()
if __name__ == "__main__":
main()
what could I do?
Thank you.