I’m at the pipe with built-ins stage. In the test, how does output of
echo raspberry\\nblueberry | wc
be 1 line and 20 characters at the same time? If I add a newline character at the end of every output of echo or any builtin/command in general, it adds an extra character so character count should be 21. If not, line should be 0 and character count should be 20? How is this possible?
Hey @MaxJuneKim, great question! This comes down to how echo behaves in Bash.
In this example, echo raspberry\\nblueberry does not interpret \n as a newline. Instead, it outputs it literally as a backslash (\) followed by the letter n.
I agree this is a bit confusing, we’ll update the instructions to make this clearer.
Yeah I understand how the string should be interpreted. if the backslash is interpreted as a literal character followed by n, the total number of characters become 20. As far as I know, on both zsh and bash, echo adds a newline character to an end, which should add an extra character, so wc would return 21.
My biggest issue is that it is not even consistent. If expected implementation is to add a new line character at the end, then expected output of wc should be 21 with 1 newline character. Otherwise, it should be 20 characters with 0 newline character. But the expected output here is 20 characters with 1 newline? How is this possible? Are we counting a new character or not? This is the part that is confusing me.
@MaxJuneKim Great catch! We’ve updated the example command to better match what the tester actually expects in this PR.
Let me know if you spot anything else!