I think there is a discrepancy between bash and the implemented specification

Hey everyone,

I’m working on the shell implementation for CodeCrafters and I’ve hit a snag with the argument tokenizer command specifications. There’s a discrepancy I’d like to get some eyes on.

The Command:

bash

echo "/tmp/cow/f\n13" "/tmp/cow/f\78" "/tmp/cow/f'\'71"

According to specs, this should output:

/tmp/cow/f\n13 /tmp/cow/f\78 /tmp/cow/f'\'71

But in my Bash shell, I’m getting:

/tmp/cow/f
13 /tmp/cow/f\78 /tmp/cow/f'\'71

The difference seems to be in how escape sequences (particularly \n) are being handled. In standard Bash, the \n inside double quotes is being interpreted as a newline character, which splits the output.

Should our implementation handle escape sequences differently than standard Bash?

This is currently causing test failures (I implemented as requested to pass the step but I’m unsure if its really correct), so I’d appreciate any insights from others who might have encountered this or from the maintainers about the expected behavior.

Thanks in advance!


Hey @eliax1996, would you mind sharing which stage you’re on, along with a screenshot of the test output and spec in question? I’d love to take a closer look and see if it’s an error on our end.

Hi Andy1li!

Thanks for the help. The test failing wasn’t literally the echo, it was a cat command over those files.
It was something like: "cat /tmp/cow/f\n13" "/tmp/cow/f\78" "/tmp/cow/f'\'71" where in the setup before it was creating the files in the right dirs.
I think I was at Backslashes in Double Quotes, I tried to bring back the code but now the tests seems to be different and its failing somewhere else, do all the tests restarts from the beginning once a stage its passed?

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

codecrafters test --previous

Let me know if you’re able to reproduce the same error.

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.