microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.42k stars 233 forks source link

`\x7f` is always converted to `\x08`/`\b` on Windows #575

Closed connorskees closed 1 year ago

connorskees commented 1 year ago

Environment details

Issue description

When writing \x7f on Windows, the input will always be converted to \x08. It is unclear where this transform is occurring. To reproduce,

// relative to examples/fork/index.js
const pty = require('../..');

// reproduces with both cmd.exe and powershell.exe
const ptyProcess = pty.spawn('cmd.exe', [], {
  name: '...',
  cols: 80,
  rows: 26,
  cwd: process.env.USERPROFILE,
  // reproduces regardless of this value
  useConpty: true,
});

ptyProcess.onData(data => process.stdout.write(data));

ptyProcess.write('python -c "import msvcrt; print(msvcrt.getch())"\r');
ptyProcess.write('\x7f');

process.on('exit', () => ptyProcess.kill());
setTimeout(() => process.exit(), 500);

image

This issue appears to be independent of the shell and is reproducible using both winpty and conpty.

Tyriar commented 1 year ago

It would be happening by conpty (https://github.com/microsoft/terminal) or cmd