GU3 - Backslash within double quotes C#

Hey, I am stuck on this and I can’t see where I am going wrong. Everything “looks” correct to me but I must be missing something.

I am getting the following failed test:

However, if I run it locally then the string I am getting back is:

/tmp/bee/number 2 /tmp/bee/doublequote " 11 /tmp/bee/backslash \ 53

Which seems correct to me, so either I’m failing to understand it or I have completely missed something stupid/insignificant.

For what it’s worth, I’m not using any third party libraries etc. I’m just looping through the chars in the string and acting accordingly.

Thanks for the assistance.

Hey @kevinmchugh1981, could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.

Hey @andy1li that should be it published to GitHub - kevinmchugh1981/codecrafters-shell-csharp

thanks for the assistance and apologies for the quality of the code.

Kevin

Ignore rest of this post, that is not the code path taken (though it should be).

You don’t seem to be actually parsing the tokens passed argument? From what I can tell you split: cat /tmp/rat/”number 2” … into command=cat and the rest of the line arguments=/tmp/rat/”number 2” … and then you pass that directly into ProcessStartInfo? From what I can tell that end up doing extremely primitive processing of startInfo.arguments not suitable for this: Source Browser

1 Like

Looking more that code path above is not taken I guess since you don’t treat catas an external command. You implemented cat yourself though I think the challenge intends you to find the program.

You run your CatCommand at codecrafters-shell-csharp/src/Commands/CatCommand.cs at b44828c60282fc18bf8883bfd021c86c4babd6d4 · kevinmchugh1981/codecrafters-shell-csharp · GitHub which ends up calling GetBetweenDelimiters. Based on your error message of "” we can guess the file paths failed and the parsing thus failed.

I didn’t do a deep dive, but it looks like when parsing something like /tmp/rat”number 2” you would keep accumulating the chars of /tmp/rat but then you hit " and you think you are done with the previous token, but you are not since the "number 2” continues the same single token! Here https://github.com/kevinmchugh1981/codecrafters-shell-csharp/blob/main/src/Parsers/ParserBase.cs#L53-L59

1 Like

@kevinmchugh1981 This looks like a quoting issue.

I tried running your code against the previous stages, but it’s actually no longer passing a previous stage #TG6 (Quoting - Double quotes).

Suggestions:

  1. Use our CLI to test against previous stages by running:
codecrafters test --previous
  1. Focus on fixing the early stages first, as later stages depend on them.

Thanks @senevoldsen and @andy1li, I do have one small question, is there a way I can run previous tests in stages? IE Run only Single Quote problem tests, then Double Quote problem tests etc. or is it an all or nothing type deal?

@kevinmchugh1981 You can rerun previous tests using our CLI in ascending order like this:

codecrafters test --previous

But we don’t support running tests for specific stages yet.

@andy1li fair enough, I’ll keel an eye for it coming in the future.

And thanks again to both you and @senevoldsen turns out the problems where less about my coding abilities and more to do with my complete failure to understand how bash actually works :smiley:

A lot of research and refactoring later I have a working branches that passes everything, up to and including this question!

1 Like

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