You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This gets somewhat more confusing since echo (or at least some implementations of it) looks at the shell lexing output and applies its own rules for escape sequences. Here's a summary of splitting behaviors, tested without relying on echo (and let's hope this table doesn't get scrambled by incompatible Markdown implementations — it reads as intended on the GitHub website):
Implementation
Result for '\n'
Result for '\\n'
bash 3.2
\n
\\n
Zsh 5.8
\n
\\n
Python shlex
\n
\\n
Rust shlex
\n
\n
So while none of these result in an actual newline, you're right about the Rust implementation being incorrect, regardless of which implementation is used as a reference point.
In shell:
So obviously shells see
\n
and\\n
differently.However, in your code:
\n
, when\
is encountered followed byn
, it pushes both\
andn
onto the result.\\n
, when\
is encountered followed by\
, it pushes\
onto the result. Then, it pushesn
onto the result.So it appears that they are treated in the same way, which as I understand, is incorrect.
The text was updated successfully, but these errors were encountered: