microsoft / microsoft/terminal
Only one part of unicode character get deleted on backspace in WSL/bash (again)
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
# Environment
Windows:
```
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 10.0.19041.0 Microsoft Windows NT 10.0.19041.0
```
WSL2:
```
PS C:\Users\eugzol> bash -li
eugzol@DESKTOP-FAV7PTR:/mnt/c/Users/eugzol $ uname -a
Linux DESKTOP-FAV7PTR 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
```
# Steps to reproduce
```
eugzol@DESKTOP-FAV7PTR:~ $ cat test.sh
read user_input
echo $user_input | xxd
eugzol@DESKTOP-FAV7PTR:~ $ chmod +x test.sh
eugzol@DESKTOP-FAV7PTR:~ $ ./test.sh
а
00000000: d0d0 b00a ....
eugzol@DESKTOP-FAV7PTR:~ $ bash -li test.sh
а
00000000: d0d0 b00a ....
eugzol@DESKTOP-FAV7PTR:~ $ echo $LANG
ru_RU.UTF-8
```
When running `test_sh` script above I enter `а` (lowercase Cyrillic letter), then press backspace, then enter `а` again, then press Enter.
Hex representation of the resultant string, as shown above, is `d0 d0b0 0a`. `d0b0` is the correct representation of `а`. First `d0` is the first byte of the `а` which was entered before pressing backspace. Second byte was deleted. Last `0a` is the new line.
# Expected behavior
Hex representation of the resultant string is `d0b0 0a`. That is, all bytes of the `а` symbol is deleted when pressing backspace.
# Actual behavior
Backspace deletes only the last byte of two-byte symbol.
Contributor guide
Research direction
Start by running the issue's test.sh under `bash -li` in WSL2 and confirm the `d0 d0b0 0a` output with `xxd`. Trace the terminal's backspace handling for multibyte input; done means deleting the Cyrillic character produces only `d0b0 0a`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, cpp
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100