Stuck on Stage Builtin completion #qp2

I’m stuck on Stage Builtin completion #qp2.

I don’t understand why I’m getting this error, I passed this testcase previously, so why does this one show error now, it’s not like I’ve added a code that directly affects this particular part.

Can someone please help me understand why am I getting this error in the first place

GitHub repo: https://github.com/logan1o1/codecrafters-shell-go

Here are my logs:

[tester::#UN3] Running tests for Stage #UN3 (Redirection - Append stderr)
[tester::#UN3] [setup] export PATH=/tmp/strawberry/apple/blueberry:$PATH
[tester::#UN3] Running ./your_program.sh
[your-program] $ ls -1 nonexistent >> /tmp/quz/bar.md
[tester::#UN3] Failed to read file ("/tmp/quz/bar.md"): open /tmp/quz/bar.md: no such file or directory
[your-program] ls: nonexistent: No such file or directory
[your-program] $ 
[tester::#UN3] Assertion failed.
[tester::#UN3] Test failed

I didn’t notice this before, but if the check is for Redirection - Append stderr,
then why is it using “>>” not “2>>”, stderr is “2>>” not the normal “>>”

1 Like

Problem solved, please close the thread

@logan1o1 What was the problem? I’m getting the same error, it’s right after ReadLine command.

readline gives you a cleaner input so instead of removing the last thing

-  newInput, newArgsArr := InputParser(input[:len(input)-1]) //instead of this
+ newInput, newArgsArr := InputParser(input)                      //just do this

Sorry, I’m still kinda confused. I’m using c# if that was not clear, so the error happens directly after reading the line like:
var line = Console.ReadLine();
Console.WriteLine("My debug outpuit");

And this is the debug output:
[your-program] $ ls -1 nonexistent >> /tmp/quz/bar.md
[tester::#UN3] Failed to read file ("/tmp/quz/bar.md"): open /tmp/quz/bar.md: no such file or directory
[your-program] My debug output

I guess I’m not reading the logs correctly and understanding the assignment. If tester::#UN3 throws an error here before I can even do anything in my code (because the error is between my readline and debug output) then by my reasoning I cannot correct this, I’m not even the one throwing an error!

Hey @Miha-Klun, the expectation is that your shell should create a file, but it looks like it didn’t?

Ok, but if you look at my code (these lines are one after the other in my code) and compare to the logs when pushing to git you see that the “fail to read file…” line is before the “My debug output” line so from that I concluded that the check if the file exists comes from somewhere else and comes too soon for me to handle. I will modify the code now so that it creates the file regardless if there is any output to it.
Also if I’m not mistaken the check if file exists was done in earlier steps with the cat command?

Thanks for your help!

1 Like

I’d just just keep printing stuff, till you see what exactly the problem is. I’ve never worked with C# so I can’t be sure what your problem is.

1 Like

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

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