In the WebContainer terminal, node -e mishandles \r and \n and other special characters when written using process.stdout.write(). Plain stdout output works. ANSI/control bytes also work.
These commands work:
node -e 'process.stdout.write("hello")'
node -e 'process.stdout.write("hello$")'
node -e 'process.stdout.write("hello" + String.fromCharCode(13) + "$")'
node -e 'process.stdout.write(Buffer.from([104,101,108,108,111,13,36]))'
node -e 'const cr="\x0d"; process.stdout.write("hello"+cr+"$")'
This command fails:
node -e 'process.stdout.write("hello\r$")'
❯ node -e "console.log('\n')"
SyntaxError: Invalid or unexpected token
at new Function (<anonymous>)
at _0x5fc7be (https://k03e2io1v3fx9wvj0vr8qd5q58o56n-f
kdo.w-credentialless-staticblitz.com/blitz.4c73681d.js:31:
853064)
Expected ',', got 'string literal (), '))'
at new _0xbd58a3 (https://k03e2io1v3fx9wvj0vr8qd5q58o5
6n-fkdo.w-credentialless-staticblitz.com/blitz.4c73681d.js
:31:855976)
at makeContextifyScript (https://k03e2io1v3fx9wvj0vr8q
d5q58o56n-fkdo.w-credentialless-staticblitz.com/builtins.4
a5e7736.js:290:1431)
at compileScript (https://k03e2io1v3fx9wvj0vr8qd5q58o5
6n-fkdo.w-credentialless-staticblitz.com/builtins.4a5e7736
.js:198:2085)
at evalTypeScript (https://k03e2io1v3fx9wvj0vr8qd5q58o
56n-fkdo.w-credentialless-staticblitz.com/builtins.4a5e773
6.js:198:3646)
at internal/main/eval_string (https://k03e2io1v3fx9wvj
0vr8qd5q58o56n-fkdo.w-credentialless-staticblitz.com/built
ins.4a5e7736.js:149:1040)
at _0x2029db (https://k03e2io1v3fx9wvj0vr8qd5q58o56n-f
kdo.w-credentialless-staticblitz.com/blitz.4c73681d.js:31:
1543178)
at _0x771053.executeBootstrapper (https://k03e2io1v3fx
9wvj0vr8qd5q58o56n-fkdo.w-credentialless-staticblitz.com/b
litz.4c73681d.js:31:783272)
at _0x6add08.startExecution (https://k03e2io1v3fx9wvj0
vr8qd5q58o56n-fkdo.w-credentialless-staticblitz.com/blitz.
4c73681d.js:31:1627371)
That suggests some layer in the command input path is converting two-character sequences e.g. \r and throwing an error.
In the WebContainer terminal,
node -emishandles\rand\nand other special characters when written using process.stdout.write(). Plainstdoutoutput works. ANSI/control bytes also work.These commands work:
node -e 'process.stdout.write("hello")'node -e 'process.stdout.write("hello$")'node -e 'process.stdout.write("hello" + String.fromCharCode(13) + "$")'node -e 'process.stdout.write(Buffer.from([104,101,108,108,111,13,36]))'node -e 'const cr="\x0d"; process.stdout.write("hello"+cr+"$")'This command fails:
node -e 'process.stdout.write("hello\r$")'That suggests some layer in the command input path is converting two-character sequences e.g.
\rand throwing an error.