magmax / python-inquirer

A collection of common interactive command line user interfaces, based on Inquirer.js (https://github.com/SBoudrias/Inquirer.js/)
MIT License
1.01k stars 97 forks source link

Getting backspace characters (0x08) in Text answers. #647

Open snps-grafael opened 2 days ago

snps-grafael commented 2 days ago

Which operating system and Python version are you using?

Server is AlmaLinux8.10, running python 3.11.2 (Python 3.11.2 (main, May 25 2024, 11:01:50) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux), ssh client is MobaXterm, setting the TERM variable to "xterm-256color". The issue only occurs using MobaXterm, so I suspect terminfo and readchar hijinks.

Which version of this project are you using?

inquirer 3.1.3 (no relevant fixes appear in the changelog) readchar 4.0.5

What did you do?

Use backspace in a Text prompt. (Same with ^W and ^U)

What did you expect to see?

The characters to delete are deleted and don't show up in the string output.

What did you see instead?

The characters to delete remain in the string output, followed by 0x08 bytes (backspace characters). The same thing happens with ^W characters (0x17, word clear characters) and ^U (0x15 clear to start characters).

Cube707 commented 2 days ago

0x08 is the Backspace-character under windows, not linux. It is expected behaviour that sending a 0x08 byte to a linux system is not detected as Backspace.

I belive this is a mobaXterm issue and it works fine over a normal ssh connection. Can you confirm?

Cube707 commented 2 days ago

This is probably related to https://github.com/magmax/python-readchar/issues/50, but I have no Idea on how to proceed towards fixing that issue.

snps-grafael commented 2 days ago

I can confirm that I can only reproduce this issue via mobaxterm, and yes, it probably is related to readchar and the TERM and terminfo for that terminal.