Skip to content

Conversation

@RazvanLiviuVarzaru
Copy link
Collaborator

NCURSES rely on terminfo database to find out what are the terminal capabilities so that keypresses are interpreted as intended.

In our case, backspace was interpreted as a simple space " ". terminfo database is available on most linux distributions by default so we just need to set the paths when compiling ncurses statically.

Example strace output of mariadb client after testing with this patch applied to ncurses:

stat("/home/razvan/.terminfo", 0x64c0fac3e450) = -1 ENOENT (No such file or directory)
stat("/etc/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/lib/terminfo", 0x64c0fac3e4e0)   = -1 ENOENT (No such file or directory)
stat("/usr/share/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/scripts/local//share/terminfo", 0x64c0fac3e570) = -1 ENOENT (No such file or directory)
access("/etc/terminfo/x/xterm-256color", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/share/terminfo/x/xterm-256color", R_OK) = 0
openat(AT_FDCWD, "/usr/share/terminfo/x/xterm-256color", O_RDONLY) = 4

And backspace works as intended.

NCURSES rely on terminfo database to find out what are the terminal capabilities
so that keypresses are interpreted as intended.

In our case, backspace was interpreted as a simple space " ".
terminfo database is available on most linux distributions by default so we
just need to set the paths when compiling ncurses statically.

Example strace output of mariadb client after testing with this patch applied to ncurses:

```
stat("/home/razvan/.terminfo", 0x64c0fac3e450) = -1 ENOENT (No such file or directory)
stat("/etc/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/lib/terminfo", 0x64c0fac3e4e0)   = -1 ENOENT (No such file or directory)
stat("/usr/share/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/scripts/local//share/terminfo", 0x64c0fac3e570) = -1 ENOENT (No such file or directory)
access("/etc/terminfo/x/xterm-256color", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/share/terminfo/x/xterm-256color", R_OK) = 0
openat(AT_FDCWD, "/usr/share/terminfo/x/xterm-256color", O_RDONLY) = 4
```

And backspace works as intended.
Copy link
Member

@cvicentiu cvicentiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configure flags align with the same ones in Debian Ncurses package, Fedora Ncurses package and partially Archlinux.

Should be ok.

@RazvanLiviuVarzaru RazvanLiviuVarzaru merged commit ebeafa1 into MariaDB:dev Feb 10, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants