Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SUSE /etc/inputrc] issues sourcing ble.sh #424

Open
Anyborr opened this issue Mar 12, 2024 · 34 comments
Open

[SUSE /etc/inputrc] issues sourcing ble.sh #424

Anyborr opened this issue Mar 12, 2024 · 34 comments
Labels
compatibility External Problem/Bug Problems/Bugs of other projects

Comments

@Anyborr
Copy link

Anyborr commented Mar 12, 2024

GNU bash, version 4.4.23(1)-release (x86_64-suse-linux) [SUSE Linux Enterprise Server 15]
ble.sh, version 0.4.0-devel4+b6344b3b (noarch) [git 2.35.3, GNU Make 4.2.1, GNU Awk 4.2.1, API: 2.0]
bash-completion, version 2.7 (hash:a379b3f832e4e804323eb4c21c12f799cc5a1987, 73857 bytes) (noarch)
locale: LANG=en_US.UTF-8
terminal: TERM=xterm-256color wcwidth=auto-auto/15.1-2+ri

After having SSH'd to a machine with ble.sh installed, sourcing the ble.sh script, either straight from the git directory or after installing the program, results in repeated messages of -bash: syntax error near unexpected token from most keypresses that are not letters A-Z or numbers. This also produces the blesh message at the top left of the terminal recieved a misencoded char U+0000 and writes weird letters to the write-line in the terminal. Blesh works fine when sourcing from a native terminal on the target machine, but does not work properly when SSH'd into the machine.

I've tried checking keymap variables are available via localectl and variables from locale look good.

For now i have to turn ble.sh off as my workflow requires me to routinely ssh into my work station.
Appreciate all help, thanks!

@akinomyoga
Copy link
Owner

Thanks for the report. I'm always using ssh, but it doesn't reproduce in my environment, and I've never experienced the behavior.

  • Q1: Could you try clearing the cache by the following command? After that, is the behavior change?
$ bash /path/to/ble.sh --clear-cache
  • Q2: What is your terminal at your local machine?
  • Q3: Was the above information from ble/widget/display-shell-version taken from the problematic session? Or was it taken from the working terminal (i.e., "the native terminal on the target machine")? What is the value of TERM in the terminal of the local machine where you attempt SSH?

@Anyborr
Copy link
Author

Anyborr commented Mar 13, 2024

Some additional info:
When I ssh to a new local computer with blesh it seems to work fine, so there must be something specific with the first machine that is causing the problem. The reason I thought it was related to SSH was because the same issue appeared when i installed blesh on a computer cluster i also ssh to.

Q1: Clearing the cache does not affect the behavior.

Q2: The machine i SSH from is using WSL2 with the default terminal app and $BASHVERSION 5.1.16(1)-release, but the issue appears also when I SSH from a terminal on a linux SUSE machine. The target machines are using linux SUSE, the computational cluster Im not sure which flavor of linux they run.

Q3: The display-shell-version was taken from the problematic machine while connected via SSH. because both of the machines I've seen the problems from are non-local I cannot log on locally to see if the same problem appears without SSH, but I suspect now that the issue is more connected to the environment and does not have to do with SSH. The TERM of my local machine is xterm-256color

When sourcing the ble.sh script on one of the problematic machines the write prompt gets filled with the character string [31;4R[31;4R[31;5R[31;5R[31;5R[31;4R[31;5R[31;5R[31;4R[31;5R[31;5R[31;5R[31;5R[31;5R[31;5R[31;5R[31;4R[2;1R[3;1R[>0;10;1c where the numbers are random for each time the script is sourced while the letters and brackets are the same. These characters dont appear when the script is reloaded, but the problematic behavior persists. These type of characters also appear on the prompt every time a non-numeric or non-A-Z key is pressed.

@akinomyoga
Copy link
Owner

Sorry for the delay in the answer. I didn't have an idea what is happening, and also I was busy.

Today, a possibility of broken /etc/inputrc in SUSE came to my mind. In the past, there were problems with the default Readline settings shipped with openSUSE (#89, #105, #268, openSUSE/aaa_base#84, openSUSE/aaa_base#140). Even if the reported systems still distribute the old broken inputrcs, I had been assuming that the workarounds for openSUSE (which ignores the broken settings) would be applied to your systems. However, I realized that the workaround explicitly checks whether the system name contains the string openSUSE. The system name in the reported system seems to be just SUSE, so I guess SUSE in the reported systems shares the basic settings with openSUSE and distributes the broken inputrcs, and in addition the workaround by ble.sh wouldn't be enabled in your systems.

@akinomyoga
Copy link
Owner

  • Q4: Does the situation change when you pass the option --inputrc=none to source /path/to/ble.sh in your remote ~/.bashrc?
# bashrc

source /path/to/ble.sh [other options if any...] --inputrc=none

Please replace /path/to/ble.sh with the path to the file ble.sh in your installation. Also, please replace [other options if any ...] with the options you already specify, if any, or remove it.

@Anyborr
Copy link
Author

Anyborr commented Mar 23, 2024

Hi, no worries, I've also been quite busy with work.

testing your suggestion in Q4 unfortunately did not produce a different result.
Below I've attached an image of the terminal directly after sourcing the ble.sh script. the gray key combinations show up automatically as a result of running the script, and the red highlighted key combinations are a result of me pressing random arrow keys in sequence directly afterwards.

image

Best,

@Anyborr Anyborr changed the title issues sourcing ble.sh when using ssh issues sourcing ble.sh Mar 23, 2024
@akinomyoga
Copy link
Owner

Thank you for your patience! Hmm, then, /etc/inputrc seems unrelated. I'd like to check what bytes ble.sh receives when you press the cursor keys.

  • Q5: Could you check the results of the following commands?
$ ble-import core-debug
$ ble/debug/keylog#start
$ [A[C[B[D[...          # <-- Could you press cursor keys here to replicate the problem?
$ ble/debug/keylog#end
        # <-- what is the output here?

I'd like to check the state of bind in the problematic session.

  • Q6: Could you attach the file produced by the following command?
$ builtin bind -spX > dump-bind.txt

You can copy the generated file dump-bind.txt to the local host using scp, and attach the text file by dragging and dropping the file into the textarea for the reply in this GitHub Issue page. After attaching the file, you can remove the file dump-bind.txt from both remote and local hosts.

@Anyborr
Copy link
Author

Anyborr commented Mar 23, 2024

Q5:

===== bytes =====
192 91 67 192 91 65 192 91 68 192 91 67
192 91 66 192 91 68 192 91 67 192 91 68
192 91 67 192 91 65 192 91 68 192 91 67
192 91 66 192 91 68 192 91 67 192 91 68
192 91 65 192 91 67 192 91 68 192 91 67
192 91 66 192 91 68 192 91 67 192 91 68
192 91 65 3 98 108 101 47 100 101 98 117
 103 47 107 101 121 108 111 103 35 101 1
10 100 13

===== chars =====
NUL [ C NUL [ A NUL [ D NUL [ C NUL [ B
NUL [ D NUL [ C NUL [ D NUL [ C NUL [ A
NUL [ D NUL [ C NUL [ B NUL [ D NUL [ C
NUL [ D NUL [ A NUL [ C NUL [ D NUL [ C
NUL [ B NUL [ D NUL [ C NUL [ D NUL [ A
ETX b l e / d e b u g / k e y l o g # e
n d RET

===== keys =====
C-@ [ C C-@ [ A C-@ [ D C-@ [ C C-@ [ B
C-@ [ D C-@ [ C C-@ [ D C-@ [ C C-@ [ A
C-@ [ D C-@ [ C C-@ [ B C-@ [ D C-@ [ C
C-@ [ D C-@ [ A C-@ [ C C-@ [ D C-@ [ C
C-@ [ B C-@ [ D C-@ [ C C-@ [ D C-@ [ A
C-c b auto_complete_enter l e / / auto_c
omplete_enter d e b u g / / auto_complet
e_enter k e y l o g # e e auto_complete_
enter n d C-m

Q6

dump-bind.txt

@akinomyoga
Copy link
Owner

Thank you for those results! With a cursor key, ble.sh is supposed to receive a byte sequence in the form 192 155 91 {65..68}. However, the result of Q5 tells that the byte 155 is missing. However, as far as I examine the attached dump-bind.txt from Q6, there doesn't seem to be any problems. The result is exactly the same as that in my environment with Bash 4.4 in the emacs editing mode. Maybe the internal state of Readline is broken for some reason. Then, I again suspect /etc/inputrc.

  • Q7: Is there any difference in the behavior between the child Bash sessions started in the following two ways?
$ bash    # <-- start a child session (#1)
$ source /path/to/ble.sh
$     # <-- check the behavior
$ exit    # <-- end the child session #1
$ INPUTRC=/dev/null bash    # <-- start another child session (#2) with INPUTRC=/dev/null
$ source /path/to/ble.sh
$     # <-- check the behavior
$ exit    # <-- end the child session #2

@akinomyoga
Copy link
Owner

OK, I could reproduce the problem with an old /etc/inputrc.keys of openSUSE using Bash 4.4. I've been preventing ble.sh from reading /etc/inputrc of openSUSE as a workaround, but I think I'll have to add another workaround to prevent even Readline from reading /etc/inputrc of openSUSE and SUSE.

@akinomyoga akinomyoga added External Problem/Bug Problems/Bugs of other projects compatibility labels Mar 23, 2024
@akinomyoga akinomyoga changed the title issues sourcing ble.sh [SUSE /etc/inputrc] issues sourcing ble.sh Mar 23, 2024
@Anyborr
Copy link
Author

Anyborr commented Mar 23, 2024

Q7: sourcing blesh within INPUTRC=/dev/null bash seems to solve the issue of keys not functioning properly. When sourcing ble.sh I still get the bash: ble/util/idle.clock: No such file or directory printout, but maybe it does not matter?

I'll test around a bit in the coming weeks and if I encounter any other problems that seems unique to the machines where i observed the issues ill add them to this thread (or if prudent, open a new issue).

Thanks for taking the time with this issue.

Best,

@akinomyoga
Copy link
Owner

akinomyoga commented Mar 23, 2024

Thanks for checking!

bash: ble/util/idle.clock: No such file or directory

This is a separate issue. I'll fix it.

@akinomyoga
Copy link
Owner

I think I'll have to add another workaround to prevent even Readline from reading /etc/inputrc of openSUSE and SUSE.

I tried to add a workaround, but I realized that the problem doesn't arise in my environment in the case where the workaround can be implemented.

  • Q8: Does the problem of broken key processing arise when source ble.sh --inputrc=none is performed inside ~/.bashrc?

I seem to be able to reproduce the problem only when I source ble.sh in the prompt. In this case, the workaround cannot be implemented because the Readline state is already broken before source ble.sh is performed. For the workaround, I assumed the case where source ble.sh is performed inside ~/.bashrc (i.e., source ble.sh is performed before Readline is initialized). However, in the case where source ble.sh is performed inside ~/.bashrc, the problem doesn't seem to happen even without the workaround.


When sourcing ble.sh I still get the bash: ble/util/idle.clock: No such file or directory printout,

I took a look into this issue, and I found the issue happens when the internal API ble/util/idle.push --sleep=* (which was recently added in commit e0566bd) is used in the initialization stage. However, as far as I know, this internal feature is not supposed to be used in the initialization stage. The reported issue might be caused differently, but I currently have no idea.

  • Q9: Do you have any custom settings for ble.sh (e.g. in ~/.blerc)?

@Anyborr
Copy link
Author

Anyborr commented Mar 24, 2024

Q8: Same as for your investigation the issues appear again when sourcing ble.sh within .bashrc, both with and without using --inputrc=none.

Q9: I don't have any additional settings for ble.sh. The configuration is "out of the box" so to say.

@akinomyoga
Copy link
Owner

Thank you for your answers.

Q8: Same as for your investigation the issues appear again when sourcing ble.sh within .bashrc, both with and without using --inputrc=none.

Then, the situation seems slightly different in my environment.

Q9: I don't have any additional settings for ble.sh. The configuration is "out of the box" so to say.

Hmm,

  • Q10: How about the other settings? Do those problems (key inputs and ble/util/idle.clock) reproduce with only ble.sh setting in ~/.bashrc?
# bashrc

source /path/to/ble.sh --norc --inputrc=none

@akinomyoga
Copy link
Owner

  • Q10: How about the other settings? Do those problems (key inputs and ble/util/idle.clock) reproduce with only ble.sh setting in ~/.bashrc?
# bashrc

source /path/to/ble.sh --norc --inputrc=none

Maybe I was a bit unclear about this. I would like to know the results when you have only the ble.sh settings in your ~/.bashrc. You can copy your original .bashrc to another file, and then put the above single line in ~/.bashrc.

# 1. back up your original .bashrc (".bashrc.original" is an example name)

[remote]$ mv ~/.bashrc ~/.bashrc.original

# 2. make sure that your original .bashrc is moved to ~/.bashrc.original

[remote]$ ls -l ~/.bashrc*

# 3. rewrite .bashrc (please replace /path/to/ble.sh with the path to ble.sh in your installation)

[remote]$ echo 'source /path/to/ble.sh --norc --inputrc=none' >> ~/.bashrc

# 4. check the behavior in a child session

[remote]$ bash

<-- see behavior here

[remote]$ exit

# 5. After finishing the test, you can recover the original settings by moving back the backed up file

[remote]$ mv ~/.bashrc.original ~/.bashrc

@akinomyoga
Copy link
Owner

  • Q10: How about the other settings? Do those problems (key inputs and ble/util/idle.clock) reproduce with only ble.sh setting in ~/.bashrc?

Do you have any updates on this issue about the error message related to ble/util/idle.clock? I added a commit in the latest push to fix a possible initialization problem of ble/util/idle.push. However, the problem only happens in a specific usage of ble/util/idle.push, which is not used in the current codebase in my understanding. So the problem you observe might be different. Could you check if the situation change for the problem of ble/util/idle.clock with the latest version of ble.sh?


Q8: Same as for your investigation the issues appear again when sourcing ble.sh within .bashrc, both with and without using --inputrc=none.

Then, the situation seems slightly different in my environment.

For the original issue of the key inputs, maybe you have some settings of bind before sourcing ble.sh.

I've checked the source code of Bash. It seems to be possible to suppress loading /etc/inputrc by putting the user configuration ~/.inputrc. I think the problem can be solved by putting an empty ~/.inputrc in your home directory of the SUSE systems. Could you try that?

@swahpy
Copy link

swahpy commented Jun 7, 2024

hi I have the same issue here about -bash: ble/util/idle.clock: No such file or directory on SUSE. what information do you need?

@akinomyoga
Copy link
Owner

@swahpy Thanks. Maybe I should check the trace log.

Could you make a file test.bashrc with the following content?

# test.bashrc

HISTFILE=~/blesh-github424.history
bleopt_debug_xtrace=~/blesh-github424.txt
source out/ble.sh --norc

Then, could you start a Bash session with this bashrc and see if the error message reproduce?

$ bash --rcfile test.bashrc
    # <-- please see if the error message reproduces
$ exit     # <-- please exit immediately

If the error message is reproduced, could you provide the file created at ~/blesh-github424.txt? To attach the .txt file to the reply, you can drag and drop the file into the textarea in the GitHub issue.

After testing, you can remove the files ~/blesh-github424.txt and ~/blesh-github424.history.

@swahpy
Copy link

swahpy commented Jun 12, 2024

hi akinomyoga, apologize for late reply. I tested according to your suggestions and attached blesh-github424.txt, please take a look. Thank you.

blesh-github424.txt

@akinomyoga
Copy link
Owner

Thank you for the log. I checked it, but I couldn't find a suspicious command. I think the error is caused outside the section that is not logged. I'll later ask you to try another test2.bashrc.

@mcepl
Copy link

mcepl commented Sep 12, 2024

BTW, just to let myself be known: I am openSUSE user myself (actually MicroOS, but those are the same Tumbleweed packages), and I don’t observe anything weird like that. I use ble.sh on my main system directly, without SSH.

@akinomyoga
Copy link
Owner

Multiple issues are discussed in this issue. I'm not sure which one you are talking about, but the original problem seemed to have been specific to SUSE but not present in openSUSE. I tested the behavior in openSUSE Tumbleweed then, but I couldn't reproduce the problem. There seem to be many ble.sh users who use openSUSE, but they don't seem to report this problem. This issue is somehow only reported by the users of SUSE Linux Enterprise.

@akinomyoga
Copy link
Owner

akinomyoga commented Sep 13, 2024

@swahpy @Anyborr Sorry for the late reply, but if you are still available and seeing the same issue of ble/util/idle.clock, could you try #424 (comment) to see if the problem arises in that setup?

@swahpy Also, could you provide the result of the following command?

$ ble/widget/display-shell-version

@swahpy @Anyborr Also, what are the results of the following commands?

$ echo "$SHELLOPTS"
$ echo "$BASHOPTS"

@mcepl
Copy link

mcepl commented Sep 13, 2024

Multiple issues are discussed in this issue. I'm not sure which one you are talking about, but the original problem seemed to have been specific to SUSE but not present in openSUSE. I tested the behavior in openSUSE Tumbleweed then, but I couldn't reproduce the problem. There seem to be many ble.sh users who use openSUSE, but they don't seem to report this problem. This issue is somehow only reported by the users of SUSE Linux Enterprise.

Interesting, I am actually an employee of SUSE, so if there is a bug in our enterprise server, there are some of my colleagues whom I may let know.

@Migelo
Copy link

Migelo commented Nov 18, 2024

I had the same problem and this thread helped me solve it! So I did some more digging around and I hope we can get this issue closed.

I am using a machine with

$ cat /etc/os-release
NAME="SLES"
VERSION="15-SP3"
VERSION_ID="15.3"
PRETTY_NAME="SUSE Linux Enterprise Server 15 SP3"
ID="sles"
ID_LIKE="suse"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:15:sp3"
DOCUMENTATION_URL="https://documentation.suse.com/"

and this saved my day!

$ INPUTRC=/dev/null source ~/.local/share/blesh/ble.sh

Here is the machine's default inputrc file:

$ cat /etc/inputrc
################################################################################
## /etc/inputrc
##
## Attempt to put different TERMs together in one readline init file.
## Copyright (c) 1997,2000,2002 SuSE Linux AG, Nuernberg, Germany.
## Copyright: 2007 SuSE  LINUX Products GmbH, Nuernberg, Germany.
##
## Author: Werner Fink
## Please send feedback to https://github.com/openSUSE/aaa_base/issues
##
################################################################################
#
# Eight bit compatible: Umlaute
#
set meta-flag on
set input-meta on
set output-meta on
set convert-meta off
set enable-meta-key off
#
# When enabled use application keypad, with XTerm the e.g.  Up key switch from
# ESC [ A over to ESC O A .  On the bash command prompt the commands
#  tput smkx
# for enter keyboard_transmit mode as well as
#  tput rmkx
# for leave keyboard_transmit mode can be used to sitch to application keypad
# and switch back
#
#$if Bash
#set enable-keypad on
#$endif
#
# VI line editing
#
# All mappings below the following line belongs to vi-command mode
set keymap vi-command
# Common standard keypad and cursor
$include /etc/inputrc.keys
#
# All mappings below the following line belongs to vi-insert mode
set keymap vi-insert
# Common standard keypad and cursor
$include /etc/inputrc.keys
#
#  EMACS line editing
#
$if mode=emacs
set keymap emacs
# Common standard keypad and cursor
$include /etc/inputrc.keys
#
# ... xterm application cursor
#
$if term=xterm
"\e\eOD":	backward-word
"\e\eOC":	forward-word
"\e\eOA":	previous-history
"\e\eOB":	next-history
"\C-\eOD":	backward-char
"\C-\eOC":	forward-char
"\C-\eOA":	previous-history
"\C-\eOB":	next-history
"\M-\eOD":	backward-word
"\M-\eOC":	forward-word
"\M-\eOA":	previous-history
"\M-\eOB":	next-history
"\C-\M-OD":	backward-char
"\C-\M-OC":	forward-char
"\C-\M-OA":	previous-history
"\C-\M-OB":	next-history
$endif
#
# Standard cursor
#
"\e\e[D":	backward-word
"\e\e[C":	forward-word
"\e\e[A":	previous-history
"\e\e[B":	next-history
"\C-\e[D":	backward-char
"\C-\e[C":	forward-char
"\C-\e[A":	previous-history
"\C-\e[B":	next-history
"\M-\e[D":	backward-word
"\M-\e[C":	forward-word
"\M-\e[A":	previous-history
"\M-\e[B":	next-history
"\C-\M-[D":	backward-char
"\C-\M-[C":	forward-char
"\C-\M-[A":	previous-history
"\C-\M-[B":	next-history
$endif
#
# end
#

I debugged the issue by creating a custom inputrc file, e.g. ~/.inputrc with content identical to /etc/inputrc above and changing my .bashrc line to

INPUTRC=~/.inputrc source ~/.local/share/blesh/ble.sh

I narrowed down the problematic line to

set keymap emacs

Commenting it fixes the issue I had and which I think made the OP @Anyborr file this issue.

Let me know @akinomyoga and @mcepl if I can help you debug this further.

@akinomyoga
Copy link
Owner

I had the same problem and this thread helped me solve it!

Thank you for the information. Which problem are you talking about? Multiple issues are discussed in this thread, so I'm not sure which problem the provided information is relevant to. Is it the issue of the error message related to ble/util/idle.clock? Or is it the issue that one cannot input any keys? Or both?

set keymap emacs

Commenting it fixes the issue I had and which I think made the OP @Anyborr file this issue.

Do you have any other settings in ~/.bashrc. I'm particularly interested in whether you have set -o vi or similar in your settings.

@Migelo
Copy link

Migelo commented Nov 18, 2024

To quote the op, this issue we both had is

After having SSH'd to a machine with ble.sh installed, sourcing the ble.sh script, either straight from the git directory or after installing the program, results in repeated messages of -bash: syntax error near unexpected token from most keypresses that are not letters A-Z or numbers. This also produces the blesh message at the top left of the terminal recieved a misencoded char U+0000 and writes weird letters to the write-line in the terminal. Blesh works fine when sourcing from a native terminal on the target machine, but does not work properly when SSH'd into the machine.

I did not have set -o vi, just -o ignoreeof and -o noclobber.

I completely removed my ~/.bash_profile, ~/.bash_login, and ~/.profile, then I modified .bashrc to read

INPUTRC=~/.inputrc source ~/.local/share/blesh/ble.sh

and the issue is still there if

set keymap emacs

is present in ~/.inputrc.

From my understanding /etc/profile is still being read by the shell. I reproduce it below for completeness.

/etc/profile
$ cat /etc/profile
# /etc/profile for SUSE Linux
#
# PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes
# will be lost during system upgrades. Instead use /etc/profile.local for
# your local settings, favourite global aliases, VISUAL and EDITOR
# variables, etc ...

#
# Check which shell is reading this file
#
norc=false
restricted=false
if test -f /proc/mounts ; then
  if ! is=$(readlink /proc/$$/exe 2>/dev/null) ; then
    case "$0" in
    *pcksh)	is=ksh	;;
    *bash)	is=bash	;;
    *)		is=sh	;;
    esac
  fi
  case "$is" in
    */bash)	is=bash
	while read -r -d $'\0' a ; do
	    case "$a" in
	    --norc)
		readonly norc=true ;;
	    --restricted)
		readonly restricted=true ;;
	    esac
	done < /proc/$$/cmdline
	case "$0" in
	sh|-sh|*/sh)
		is=sh	;;
	esac		;;
    */ash)	is=ash  ;;
    */dash)	is=ash  ;;
    */ksh)	is=ksh  ;;
    */ksh93)	is=ksh  ;;
    */pdksh)	is=ksh  ;;
    */mksh)	is=ksh  ;;
    */lksh)	is=ksh  ;;
    */*pcksh)	is=ksh  ;;
    */zsh)	is=zsh  ;;
    */*)	is=sh   ;;
  esac
  #
  # `r' in $- occurs *after* system files are parsed
  #
  for a in $SHELL ; do
    case "$a" in
      */r*sh)
        readonly restricted=true ;;
      -r*|-[!-]r*|-[!-][!-]r*)
        readonly restricted=true ;;
      --restricted)
        readonly restricted=true ;;
    esac
  done
  unset a
else
  is=sh
fi

#
# Call common progams from /bin or /usr/bin only
#
_path ()
{
    command -p ${1+"$@"}
}

#
# Initialize terminal
#
tty=`_path tty 2> /dev/null`
test $? -ne 0 && tty=""
if test -O "$tty" -a -n "$PS1"; then
    test -z "${TERM}"		&& { TERM=linux; export TERM; }
    test "${TERM}" = "unknown"	&& { TERM=linux; export TERM; }
    test "${TERM}" = "ibm327x"	&& { TERM=dumb;  export TERM; }
    if test "$(uname -m)" = "s390x" ; then
	if test "$tty" = "/dev/sclp_line0" -o "$tty" = "/dev/ttyS0" ; then
	    test "${TERM}" = "vt220" && { TERM=dumb;  export TERM; }
	fi
    fi
    case "$TERM" in
    screen.*)
	test -e /usr/share/terminfo/s/${TERM} || { TERM=screen;  export TERM; } ;;
    esac
    # Do not change settings on local line if connected to remote
    if test -z "$SSH_TTY" -a "${TERM}" != "dumb" ; then
	_path stty sane cr0 pass8 dec
	_path tset -I -Q
    fi
fi
unset TERMCAP

#
# Time until a complete key sequence must have arrived
#
#ESCDELAY=2000
#export ESCDELAY

#
# The user file-creation mask
#
# The global umask value is stored in /etc/login.defs and
# will be set by pam_umask.so (see "man pam_umask").
#umask 022

#
# Setup for gzip and (t)csh users
#
if test -z "$PROFILEREAD" ; then
    # GZIP=-9
    # export GZIP
    CSHEDIT=emacs
    export CSHEDIT
fi

#
# ksh/ash sometimes do not know
#
test -z "$UID"  && readonly  UID=`_path id -ur 2> /dev/null`
test -z "$EUID" && readonly EUID=`_path id -u  2> /dev/null`
test -z "$USER" && USER=`_path id -un 2> /dev/null`
test -z "$MAIL" && MAIL=/var/spool/mail/$USER
if test -x /bin/uname ; then
    test -z "$HOST" && HOST=`/bin/uname -n`
    test "$HOST" = "localhost" && HOST=`/bin/uname -n`
    test -z "$CPU"  &&  CPU=`/bin/uname -m`
fi
# Remark: /proc/sys/kernel/domainname and the program domainname
# its self will provide the NIS/YP domainname, see domainname(8).
if test -s /etc/HOSTNAME ; then
    test -z "$HOSTNAME" && HOSTNAME=`cat /etc/HOSTNAME`
else
    test -z "$HOSTNAME" && HOSTNAME=$HOST
fi
test -z "$LOGNAME"  && LOGNAME=$USER
case "$CPU" in
    i?86) HOSTTYPE=i386   ;;
    *)    HOSTTYPE=${CPU} ;;
esac
  OSTYPE=linux
MACHTYPE=${CPU}-suse-${OSTYPE}
# Do NOT export UID, EUID, USER, and LOGNAME
export MAIL HOST CPU HOSTNAME HOSTTYPE OSTYPE MACHTYPE

#
# You may use /etc/initscript, /etc/profile.local or the
# ulimit package instead to set up ulimits and your PATH.
#
# if test "$is" != "ash" -a ! -r /etc/initscript; then
#     ulimit -Sc 0		# don't create core files
#     ulimit -Sd $(ulimit -Hd)
#     ulimit -Ss $(ulimit -Hs)
#     ulimit -Sm $(ulimit -Hm)
# fi

#
# Make path more comfortable
#
# save current path setting, we might want to restore it
ORIG_PATH=$PATH
#
if test -z "$PROFILEREAD" ; then
    PATH=/usr/local/bin:/usr/bin:/bin
    if test "$HOME" != "/" ; then
	for dir in $HOME/bin/$CPU $HOME/bin $HOME/.local/bin/$CPU $HOME/.local/bin ; do
	    test -d $dir && PATH=$dir:$PATH
	done
    fi
    if test "$UID" = 0 ; then
	test -d /opt/kde3/sbin  && PATH=/opt/kde3/sbin:$PATH
	PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
    fi
    for dir in	/usr/X11/bin \
		/usr/X11R6/bin \
		/var/lib/dosemu \
		/usr/games \
		/opt/bin \
		/opt/kde3/bin \
		/opt/kde2/bin \
		/opt/kde/bin \
		/usr/openwin/bin \
		/opt/cross/bin
    do
	test -d $dir && PATH=$PATH:$dir
    done
    unset dir
    export PATH
fi

#
# Most bourn shell clones knows about this
#
if test -z "$PROFILEREAD" ; then
    HISTSIZE=1000
    export HISTSIZE
fi

#
# Set some environment variables for TeX/LaTeX (Not used due luatex)
#
#if test -n "$TEXINPUTS" ; then
#    TEXINPUTS=":$TEXINPUTS:$HOME/.TeX:/usr/share/doc/.TeX:/usr/doc/.TeX"
#else
#    TEXINPUTS=":$HOME/.TeX:/usr/share/doc/.TeX:/usr/doc/.TeX"
#fi
#export TEXINPUTS

#
# Configure the default pager on SUSE Linux
#
if test -z "$LESS" -a -x /usr/bin/less ; then
    LESS="-M -I -R"
    LESSOPEN="lessopen.sh %s"
    LESSCLOSE="lessclose.sh %s %s"
    LESS_ADVANCED_PREPROCESSOR="no"
    if test -s /etc/lesskey.bin ; then
	LESSKEY=/etc/lesskey.bin
    fi
    PAGER=less
    MORE=-sl
    export LESSOPEN LESSCLOSE LESS LESSKEY PAGER LESS_ADVANCED_PREPROCESSOR MORE
fi

#
# Minicom
#
if test -z "$PROFILEREAD" ; then
    MINICOM="-c on"
    export MINICOM
fi

#
# Current manpath
#
if test -z "$PROFILEREAD" ; then
    tmp="$MANPATH"
    unset MANPATH
    if test -n "$tmp" ; then
	MANPATH="${tmp}:`test -x /usr/bin/manpath && /usr/bin/manpath -q`"
    else
	MANPATH="`test -x /usr/bin/manpath && /usr/bin/manpath -q`"
    fi
    unset tmp
    export MANPATH
fi

#
# Some applications do not handle the XAPPLRESDIR environment properly,
# when it contains more than one directory. More than one directory only
# makes sense if you have a client with /usr mounted via nfs and you want
# to configure applications machine dependent. Uncomment the lines below
# if you want this.
#
#XAPPLRESDIR="$XAPPLRESDIR:/var/X11R6/app-defaults:/usr/X11R6/lib/X11/app-defaults"
#export XAPPLRESDIR

#
# These settings are recommended for old motif applications
#
if test -z "$PROFILEREAD" ; then
    if [ -r /usr/share/X11/XKeysymDB ]; then
	export XKEYSYMDB=/usr/share/X11/XKeysymDB
    else
	export XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
    fi
    if [ -d /usr/share/X11/nls ]; then
	export XNLSPATH=/usr/share/X11/nls
    else
	export XNLSPATH=/usr/X11R6/lib/X11/nls
    fi

    #
    # Midnight Commander needs this to run in color mode
    #
    COLORTERM=1
    export COLORTERM
fi

#
# For RCS
#
#VERSION_CONTROL=numbered
#export VERSION_CONTROL

#
# Source profile.d files and UTF8 settings
#
# But do not source this if PROFILEREAD is already set to avoid
# overriding locale variables already present in the environment
#
if test -z "$PROFILEREAD" ; then
    test -r /etc/profile.d/sh.ssh && . /etc/profile.d/sh.ssh
fi

#
# Source profile extensions for certain packages, the super
# may disable some of them by setting the sticky bit.
#
if test -d /etc/profile.d -a -z "$PROFILEREAD" ; then
    for s in /etc/profile.d/*.sh ; do
	test -r $s -a ! -k $s && . $s
    done
    unset s
fi

if test "$is" != "ash" ; then
    #
    # And now let's see if there is a local profile
    # (for options defined by your sysadmin, not SUSE Linux)
    #
    test -s /etc/profile.local && . /etc/profile.local
fi

#
# Avoid overwriting user settings if called twice
#
if test -z "$PROFILEREAD" ; then
    readonly PROFILEREAD=true
    export PROFILEREAD
fi

#
# Standard ssh command does not do an login, therefore
# /etc/profile will be sourced by /etc/bash.bashrc
#
if test -z "$_SOURCED_FOR_SSH" -a "$norc" != true ; then
    #
    # System BASH specials, maybe also good for other shells
    # Note that ksh always reads /etc/ksh.kshrc
    #
    if test "$is" != ksh -a "$is" != zsh ; then
	_is_save=$is
	test -r /etc/bash.bashrc && . /etc/bash.bashrc
	is=$_is_save
	unset _is_save
    fi
    if test "$restricted" = true ; then
	readonly _HOMEBASHRC=true
    fi
    if test "$is" = "bash" -a -z "$_HOMEBASHRC" ; then
	# loop detection
	readonly _HOMEBASHRC=true
	test -r $HOME/.bashrc && . $HOME/.bashrc
    fi

    #
    # KSH specials
    #
    if test "$is" = "ksh" -a -r /etc/ksh.kshrc ; then
	if test "$restricted" = true ; then
	    readonly _HOMEKSHRC=true
	fi
	if test ! /etc/bash.bashrc -ef /etc/ksh.kshrc ; then
	    test -r /etc/bash.bashrc && . /etc/bash.bashrc
	fi
	if test -n "$ENV" -a "$ENV" != "\$HOME/.kshrc" -a "$ENV" != "$HOME/.kshrc" -a -z "$_HOMEKSHRC" ; then
	    # loop detection
	    readonly _HOMEKSHRC=true
	    test -r $HOME/.kshrc && . $HOME/.kshrc
	fi
    fi
fi
if test "$restricted" = true ; then
    PATH=/usr/lib/restricted/bin
    export PATH
fi

#
# An X session
#
case "$-" in
*i*)
    if test "$TERM" = "xterm" -a -O "$tty" -a -z "${SSH_TTY}" ; then
	echo "Directory: $PWD"
	# Last but not least
	date
    fi ;;
esac
unset ORIG_PATH
unset is

#
# End of /etc/profile
#

@akinomyoga
Copy link
Owner

akinomyoga commented Nov 18, 2024

From my understanding /etc/profile is still being read by the shell. I reproduce it below for completeness.

/etc/profile

Could you test your ~/.inputrc within a Bash session started with this? This doesn't load /etc/profile so can be used to check if /etc/profile is related.

$ INPUTRC=~/.inputrc bash --noprofile --rcfile ~/.local/share/blesh/ble.sh

Edit: Before testing the above, please back up your ~/.bash_history. If Bash is loaded without any settings, it will truncate your history to 500 lines.

@bitstreamout
Copy link

I can not reproduce here ... terminal is a real XTerm TERM variable is set to xterm-256color, locale LANG=C.UTF-8 and LC_CTYPE=de_DE.UTF-8 ... it simply works with Leap 15.4 and OpenSUSE Slowroll. Even ssh from the Leap based work station to the Slowroll works. Please make sure that the input.key is uptodate means that the 8bit controls are disabled openSUSE/aaa_base#84

@akinomyoga
Copy link
Owner

akinomyoga commented Nov 18, 2024

@bitstreamout Thank you for your input! So, has anyone reported this issue to openSUSE? If so, I'd appreciate it if you could share the pointer to the discussion.

Also, there is information that I got from the observation in the @Migelo's report but I didn't explicitly write here.

it simply works with Leap 15.4 and OpenSUSE Slowroll.

What is "Leap 15.4"? Based on my guess from the search result, is it a version of openSUSE?

As I've already written in #424 (comment) and #424 (comment), the issue seems to be present only in SUSE Enterprise Linux Server (SLES). While no openSUSE users report this issue, three users @Anyborr @swahpy @Migelo reported the issue for SLES 15. It shouldn't be just because there would be no ble.sh users in openSUSE. Based on the issues I received so far, openSUSE is far more popular than SLES among the ble.sh users, yet no openSUSE users report this issue. The content of /etc/inputrc provided by @Migelo shows that /etc/inputrc shipped with SLES 15.3 is still a pre-aaa_base#84 version. It is reasonable to guess /etc/inputrc.keys in SLES 15.3 is also still a pre-aaa_base#84 version.

@bitstreamout Then, a question is: To what versions of openSUSE and SLES was aaa_base#84 applied? From the reports so far, it seems to have been applied to openSUSE Leap 15.4 but hasn't been applied to SLES 15.3. How about openSUSE Leap 15.3? How about SLES 15.4?

@bitstreamout
Copy link

Leap 15.4 is an openSUSE clone from SLE-14-SP4 with some extensions where as Slowroll is the slow rolling release of Tumbleweed. Currently actual is Leap 15.6 (and 15.5 is still gets updates) and for SLES we still have SLE-15-SP5 as well as the new SLE-15-SP6 ... also the question rises if all updates are applied ... at least this one:

Thu Sep 30 08:51:55 UTC 2021

- Include all fixes and changes for systemwide inputrc to remove
  the 8 bit escape sequence which interfere with UTF-8 multi byte
  characters as well as support the vi mode of readline library.
  This is done with the patches
  * git-41-f00ca2600331602241954533a1b1610d1da57edf.patch
  * git-42-f39a8d18719c3b34373e0e36098f0f404121b5c5.patch
  before the changed patch
    git-13-14003c19eaa863ae9d80a0ebb9b5cab6273a5a9e.patch
  rename it to
    git-43-14003c19eaa863ae9d80a0ebb9b5cab6273a5a9e.patch
  and also add the patches
  * git-44-425f3e9b44ba9ead865d70ff6690d5f2869442dc.patch
  * git-45-bf0a31597d0ed3562bfc5e6be0ade2fe5dc1f7a1.patch

visible with rpm -q --changelog aaa_base | less

@akinomyoga
Copy link
Owner

akinomyoga commented Nov 18, 2024

Leap 15.4 is an openSUSE clone from SLE-14-SP4 with some extensions

Thank you for the information. So, Leap is actually downstream of SLES. Then, we can guess SLES 15.3 and openSUSE Leap 15.3 have the old /etc/inputrc and /etc/inputrc.keys while SLES 15.4 and openSUSE Leap 15.4 have the fixed /etc/inputrc and etc/inputrc.keys. The reason that the openSUSE users wouldn't report the problem is probably because they can update it to the latest version of openSUSE for free (or they are just using Tumbleweed) while SLES servers are maintained for a long time without the major upgrade of the system.

@bitstreamout Do you think there is a possibility of backporting the fixed /etc/inputrc and /etc/inputrc.keys to the previous versions of SLES? With the current combination of an old Bash version and /etc/inputrc{,.keys}, the internal state of Readline is broken in an unrecoverable way. Even if one tries to overwrite the settings set up by the old /etc/inputrc{,.key}, the Readline doesn't seem to function correctly once the old /etc/inputrc{,.key} is loaded. Since /etc/inputrc{,.key} is (mostly) forcibly loaded in Bash sessions, there is no way for ble.sh to prevent Readline from being broken by /etc/inputrc{,.key}.

@Migelo Which version of Bash does your system have? If possible, could you install the latest version of Bash in the system using a tarball or any other ways and test if the problem is worked around?

@Migelo
Copy link

Migelo commented Nov 18, 2024

Could you test your ~/.inputrc within a Bash session started with this? This doesn't load /etc/profile so can be used to check if /etc/profile is related.

$ INPUTRC=~/.inputrc bash --noprofile --rcfile ~/.local/share/blesh/ble.sh

Edit: Before testing the above, please back up your ~/.bash_history. If Bash is loaded without any settings, it will truncate your history to 500 lines.

I use atuin for bash history, so no problem :) Thanks for the concern.

I again moved my .bashrc and .profile away. This time I left .bashrc empty, unlike in my test above where I left the line sourcing ble.sh in.

I then started a shell and ran your command

$ INPUTRC=~/.inputrc bash --noprofile --rcfile ~/.local/share/blesh/ble.sh

which broke my prompt, with a received a misencoded char U+0000 appearing at the top and this characters appearing in my input line

$ [25;4R[25;4R[25;5R[25;5R[25;5R[25;4R[25;3R[25;5R[25;4R[25;5R[25;5R[25;5R[25;5R[25;5R[25;5R[25;5R[25;4R[2;1R[3;1R[>64;2500;0c

This was with the full content of /etc/inputrc copied into my ~/.inputrc.
With the power ob bisection I narrowed down the culprit down to a different line this time. Now it seems to be

$include /etc/inputrc.keys

File contents below.

/etc/inputrc.keys
################################################################################
## /etc/inputrc.keys -- common key escape sequences
##
## Copyright: 2017 SUSE Linux GmbH, Nürnberg, Germany.
##
## Author: Werner Fink
## Please send feedback to https://github.com/openSUSE/aaa_base/issues
##
################################################################################
#
# Common standard keypad and cursor
#
"\e[1~":	beginning-of-line
"\e[2~":	yank
"\e[3~":	delete-char
"\e[4~":	end-of-line
"\e[5~":	history-search-backward
"\e[6~":	history-search-forward
"\M-[1~":	beginning-of-line
"\M-[2~":	yank
"\M-[3~":	delete-char
"\M-[4~":	end-of-line
"\M-[5~":	history-search-backward
"\M-[6~":	history-search-forward
"\2331~":	beginning-of-line
"\2332~":	yank
"\2333~":	delete-char
"\2334~":	end-of-line
"\2335~":	history-search-backward
"\2336~":	history-search-forward
#
# Cursor keys
#
"\e[C":		forward-char
"\e[D":		backward-char
"\e[A":		previous-history
"\e[B":		next-history
"\217C":	forward-char
"\217D":	backward-char
"\217A":	previous-history
"\217B":	next-history
"\233C":	forward-char
"\233D":	backward-char
"\233A":	previous-history
"\233B":	next-history
#
# Cursor keys in keypad mode
#
"\C-[OD":       backward-char
"\C-[OC":       forward-char
"\C-[OA":       previous-history
"\C-[OB":       next-history
#
# Cursor keys in ANSI mode
#
"\C-[[D":       backward-char
"\C-[[C":       forward-char
"\C-[[A":       previous-history
"\C-[[B":       next-history
#
# Cursor keys in 8 bit keypad mode
#
"\C-\M-OD":      backward-char
"\C-\M-OC":      forward-char
"\C-\M-OA":      previous-history
"\C-\M-OB":      next-history
#
# Cursor keys in 8 bit ANSI mode
#
"\C-\M-[D":      backward-char
"\C-\M-[C":      forward-char
"\C-\M-[A":      previous-history
"\C-\M-[B":      next-history
"\C-^[[D":      backward-char
$if term=xterm
"\e[2;2~":	yank
"\e[3;2~":	delete-char
"\e[5;2~":	history-search-backward
"\e[6;2~":	history-search-forward
"\e[2;3~":	yank
"\e[3;3~":	delete-char
"\e[5;3~":	history-search-backward
"\e[6;3~":	history-search-forward
"\e[2;4~":	yank
"\e[3;4~":	delete-char
"\e[5;4~":	history-search-backward
"\e[6;4~":	history-search-forward
"\e[2;5~":	yank
"\e[3;5~":	delete-char
"\e[5;5~":	history-search-backward
"\e[6;5~":	history-search-forward
"\e[2;6~":	yank
"\e[3;6~":	delete-char
"\e[5;6~":	history-search-backward
"\e[6;6~":	history-search-forward
"\e[2;7~":	yank
"\e[3;7~":	delete-char
"\e[5;7~":	history-search-backward
"\e[6;7~":	history-search-forward
"\e[2;8~":	yank
"\e[3;8~":	delete-char
"\e[5;8~":	history-search-backward
"\e[6;8~":	history-search-forward
$endif
$if term=xterm
"\e[E":		re-read-init-file
"\e[1;2E":	re-read-init-file
"\e[1;3E":	re-read-init-file
"\e[1;4E":	re-read-init-file
"\e[1;5E":	re-read-init-file
"\e[1;6E":	re-read-init-file
"\e[1;7E":	re-read-init-file
"\e[1;8E":	re-read-init-file
"\e[2C":	forward-word
"\e[2D":	backward-word
"\e[2A":	history-search-backward
"\e[2B":	history-search-forward
"\e[1;2C":	forward-word
"\e[1;2D":	backward-word
"\e[1;2A":	history-search-backward
"\e[1;2B":	history-search-forward
"\e[1;3C":	forward-word
"\e[1;3D":	backward-word
"\e[1;3A":	history-search-backward
"\e[1;3B":	history-search-forward
"\e[1;4C":	forward-word
"\e[1;4D":	backward-word
"\e[1;4A":	history-search-backward
"\e[1;4B":	history-search-forward
"\e[5C":	forward-word
"\e[5D":	backward-word
"\e[5A":	history-search-backward
"\e[5B":	history-search-forward
"\e[1;5C":	forward-word
"\e[1;5D":	backward-word
"\e[1;5A":	history-search-backward
"\e[1;5B":	history-search-forward
"\e[1;6C":	forward-word
"\e[1;6D":	backward-word
"\e[1;6A":	history-search-backward
"\e[1;6B":	history-search-forward
"\e[1;7C":	forward-word
"\e[1;7D":	backward-word
"\e[1;7A":	history-search-backward
"\e[1;7B":	history-search-forward
"\e[1;8C":	forward-word
"\e[1;8D":	backward-word
"\e[1;8A":	history-search-backward
"\e[1;8B":	history-search-forward
"\2332C":	forward-word
"\2332D":	backward-word
"\2332A":	history-search-backward
"\2332B":	history-search-forward
"\2331;2C":	forward-word
"\2331;2D":	backward-word
"\2331;2A":	history-search-backward
"\2331;2B":	history-search-forward
"\2331;3C":	forward-word
"\2331;3D":	backward-word
"\2331;3A":	history-search-backward
"\2331;3B":	history-search-forward
"\2331;4C":	forward-word
"\2331;4D":	backward-word
"\2331;4A":	history-search-backward
"\2331;4B":	history-search-forward
"\2335C":	forward-word
"\2335D":	backward-word
"\2335A":	history-search-backward
"\2335B":	history-search-forward
"\2331;5C":	forward-word
"\2331;5D":	backward-word
"\2331;5A":	history-search-backward
"\2331;5B":	history-search-forward
"\2331;6C":	forward-word
"\2331;6D":	backward-word
"\2331;6A":	history-search-backward
"\2331;6B":	history-search-forward
"\2331;7C":	forward-word
"\2331;7D":	backward-word
"\2331;7A":	history-search-backward
"\2331;7B":	history-search-forward
"\2331;8C":	forward-word
"\2331;8D":	backward-word
"\2331;8A":	history-search-backward
$else
"\e[G":		re-read-init-file
$endif
#
# Avoid network problems
#   ... \177 (ASCII-DEL) and \010 (ASCII-BS)
#       do `backward-delete-char'
# Note: `delete-char' is maped to \033[3~
#       Therefore xterm's responce on pressing
#       key Delete or KP-Delete should be
#       \033[3~ ... NOT \177
#
"\C-?":		backward-delete-char
"\C-H":		backward-delete-char
$if term=xterm
"\e\303\277":	backward-kill-word
"\eÿ"		backward-kill-word
$endif
#
# Home and End
#
$if term=xterm
#
# Normal keypad and cursor of xterm
#
"\e[1~":	history-search-backward
"\e[4~":	set-mark
"\e[H":		beginning-of-line
"\e[F":		end-of-line
"\2171~":	history-search-backward
"\2174~":	set-mark
"\217H":	beginning-of-line
"\217F":	end-of-line
"\e[1;2H":	beginning-of-line
"\e[1;2F":	end-of-line
"\e[1;3H":	beginning-of-line
"\e[1;3F":	end-of-line
"\e[1;4H":	beginning-of-line
"\e[1;4F":	end-of-line
"\e[1;5H":	beginning-of-line
"\e[1;5F":	end-of-line
"\e[1;6H":	beginning-of-line
"\e[1;6F":	end-of-line
"\e[1;7H":	beginning-of-line
"\e[1;7F":	end-of-line
"\e[1;8H":	beginning-of-line
"\e[1;8F":	end-of-line
"\2331;2H":	beginning-of-line
"\2331;2F":	end-of-line
"\2331;3H":	beginning-of-line
"\2331;3F":	end-of-line
"\2331;4H":	beginning-of-line
"\2331;4F":	end-of-line
"\2331;5H":	beginning-of-line
"\2331;5F":	end-of-line
"\2331;6H":	beginning-of-line
"\2331;6F":	end-of-line
"\2331;7H":	beginning-of-line
"\2331;7F":	end-of-line
"\2331;8H":	beginning-of-line
"\2331;8F":	end-of-line
"\e[2H":	beginning-of-line
"\e[2F":	end-of-line
"\e[5H":	beginning-of-line
"\e[5F":	end-of-line
# Home and End of application keypad and cursor of xterm
"\eOH":		beginning-of-line
"\eOF":		end-of-line
"\eO2H":	beginning-of-line
"\eO2F":	end-of-line
"\eO5H":	beginning-of-line
"\eO5F":	end-of-line
$else
$if term=kvt
"\e[1~":	history-search-backward
"\e[4~":	set-mark
"\eOH":		beginning-of-line
"\eOF":		end-of-line
$endif
#
# TERM=linux or console or gnome
#
"\e[1~":	beginning-of-line
"\e[4~":	end-of-line
$endif
#
# Application keypad and cursor of xterm
#
$if term=xterm
"\eOD":         backward-char
"\eOC":         forward-char
"\eOA":         previous-history
"\eOB":         next-history
"\eOE":         re-read-init-file
"\217E":	re-read-init-file
"\eO2D":        backward-word
"\eO2C":        forward-word
"\eO2A":        history-search-backward
"\eO2B":        history-search-forward
"\eO3D":        backward-word
"\eO3C":        forward-word
"\eO3A":        history-search-backward
"\eO3B":        history-search-forward
"\eO4D":        backward-word
"\eO4C":        forward-word
"\eO4A":        history-search-backward
"\eO4B":        history-search-forward
"\eO5D":        backward-word
"\eO5C":        forward-word
"\eO5A":        history-search-backward
"\eO5B":        history-search-forward
"\eO6D":        backward-word
"\eO6C":        forward-word
"\eO6A":        history-search-backward
"\eO6B":        history-search-forward
"\eO7D":        backward-word
"\eO7C":        forward-word
"\eO7A":        history-search-backward
"\eO7B":        history-search-forward
"\eO8D":        backward-word
"\eO8C":        forward-word
"\eO8A":        history-search-backward
"\eO8B":        history-search-forward
# DEC keyboard KP_F1 - KP_F4 or
# XTerm of XFree86 in VT220 mode F1 - F4
"\eOP":		"\e"
"\eOQ":		undo
"\eOR":		""
"\eOS":		kill-line
"\eO2P":	"\e"
"\eO2Q":	undo
"\eO2R":	""
"\eO2S":	kill-line
"\eO3P":	"\e"
"\eO3Q":	undo
"\eO3R":	""
"\eO3S":	kill-line
"\eO4P":	"\e"
"\eO4Q":	undo
"\eO4R":	""
"\eO4S":	kill-line
"\eO5P":	"\e"
"\eO5Q":	undo
"\eO5R":	""
"\eO5S":	kill-line
"\eO6P":	"\e"
"\eO6Q":	undo
"\eO6R":	""
"\eO6S":	kill-line
"\eO7P":	"\e"
"\eO7Q":	undo
"\eO7R":	""
"\eO7S":	kill-line
"\eO8P":	"\e"
"\eO8Q":	undo
"\eO8R":	""
"\eO8S":	kill-line
"\eO1;2P":	"\e"
"\eO1;2Q":	undo
"\eO1;2R":	""
"\eO1;2S":	kill-line
"\eO1;3P":	"\e"
"\eO1;3Q":	undo
"\eO1;3R":	""
"\eO1;3S":	kill-line
"\eO1;4P":	"\e"
"\eO1;4Q":	undo
"\eO1;4R":	""
"\eO1;4S":	kill-line
"\eO1;5P":	"\e"
"\eO1;5Q":	undo
"\eO1;5R":	""
"\eO1;5S":	kill-line
"\eO1;6P":	"\e"
"\eO1;6Q":	undo
"\eO1;6R":	""
"\eO1;6S":	kill-line
"\eO1;7P":	"\e"
"\eO1;7Q":	undo
"\eO1;7R":	""
"\eO1;7S":	kill-line
"\eO1;8P":	"\e"
"\eO1;8Q":	undo
"\eO1;8R":	""
"\eO1;8S":	kill-line
"\217P":	"\e"
"\217Q":	undo
"\217R":	""
"\217S":	kill-line
$endif
$if term=gnome
# or gnome terminal F1 - F4
"\eOP":		"\e"
"\eOQ":		undo
"\eOR":		""
"\eOS":		kill-line
$endif
#
# Function keys F1 - F12
#
$if term=linux
#
# On console the first five function keys
#
"\e[[A":	"\e"
"\e[[B":	undo
"\e[[C":	""
"\e[[D":	kill-line
"\e[[E":	""
$else
#
# The first five standard function keys
#
"\e[11~":	"\e"
"\e[12~":	undo
"\e[13~":	""
"\e[14~":	kill-line
"\e[15~":	""
"\23315~":	""
$endif
"\e[17~":	""
"\e[18~":	""
"\e[19~":	""
"\e[20~":	""
"\e[21~":	""
"\e[23~":	""
"\e[24~":	""
"\e[25~":	""
"\e[26~":	""
# DEC keyboard: F15=\e[28~ is Help
"\e[28~":	""
# DEC keyboard: F16=\e[29~ is Menu
"\e[29~":	""
"\e[31~":	""
"\e[32~":	""
"\e[33~":	""
"\e[34~":	""
"\e[35~":	""
"\e[36~":	""
"\23317~":	""
"\23318~":	""
"\23319~":	""
"\23320~":	""
"\23321~":	""
"\23323~":	""
"\23324~":	""
"\23325~":	""
"\23326~":	""
"\23328~":	""
"\23329~":	""
"\23331~":	""
"\23332~":	""
"\23333~":	""
"\23334~":	""
"\23335~":	""
"\23336~":	""
$if term=xterm
"\e[1;2P":	""
"\e[1;2Q":	""
"\e[1;2R":	""
"\e[1;2S":	""
"\e[15;2~":	""
"\e[17;2~":	""
"\e[18;2~":	""
"\e[19;2~":	""
"\e[20;2~":	""
"\e[21;2~":	""
"\e[23;2~":	""
"\e[24;2~":	""
"\e[1;3P":	""
"\e[1;3Q":	""
"\e[1;3R":	""
"\e[1;3S":	""
"\e[15;3~":	""
"\e[17;3~":	""
"\e[18;3~":	""
"\e[19;3~":	""
"\e[20;3~":	""
"\e[21;3~":	""
"\e[23;3~":	""
"\e[24;3~":	""
"\e[1;4P":	""
"\e[1;4Q":	""
"\e[1;4R":	""
"\e[1;4S":	""
"\e[15;4~":	""
"\e[17;4~":	""
"\e[18;4~":	""
"\e[19;4~":	""
"\e[20;4~":	""
"\e[21;4~":	""
"\e[23;4~":	""
"\e[24;4~":	""
"\e[1;5P":	""
"\e[1;5Q":	""
"\e[1;5R":	""
"\e[1;5S":	""
"\e[15;5~":	""
"\e[17;5~":	""
"\e[18;5~":	""
"\e[19;5~":	""
"\e[20;5~":	""
"\e[21;5~":	""
"\e[23;5~":	""
"\e[24;5~":	""
"\e[1;6P":	""
"\e[1;6Q":	""
"\e[1;6R":	""
"\e[1;6S":	""
"\e[15;6~":	""
"\e[17;6~":	""
"\e[18;6~":	""
"\e[19;6~":	""
"\e[20;6~":	""
"\e[21;6~":	""
"\e[23;6~":	""
"\e[24;6~":	""
"\e[1;7P":	""
"\e[1;7Q":	""
"\e[1;7R":	""
"\e[1;7S":	""
"\e[15;7~":	""
"\e[17;7~":	""
"\e[18;7~":	""
"\e[19;7~":	""
"\e[20;7~":	""
"\e[21;7~":	""
"\e[23;7~":	""
"\e[24;7~":	""
"\e[1;8P":	""
"\e[1;8Q":	""
"\e[1;8R":	""
"\e[1;8S":	""
"\e[15;8~":	""
"\e[17;8~":	""
"\e[18;8~":	""
"\e[19;8~":	""
"\e[20;8~":	""
"\e[21;8~":	""
"\e[23;8~":	""
"\e[24;8~":	""
$endif
#
$if term=xterm
#
# Application keypad and cursor of xterm
# with NumLock ON
#
# Operators
"\eOo":		"/"
"\eOj":		"*"
"\eOm":		"-"
"\eOk":		"+"
"\eOl":		","
"\eOM":		accept-line
"\eOn":		"."
# Numbers
"\eOp":		"0"
"\eOq":		"1"
"\eOr":		"2"
"\eOs":		"3"
"\eOt":		"4"
"\eOu":		"5"
"\eOv":		"6"
"\eOw":		"7"
"\eOx":		"8"
"\eOy":		"9"
# Operators
"\217o":	"/"
"\217j":	"*"
"\217m":	"-"
"\217k":	"+"
"\217l":	","
"\217M":	accept-line
"\217n":	"."
# Numbers
"\217p":	"0"
"\217q":	"1"
"\217r":	"2"
"\217s":	"3"
"\217t":	"4"
"\217u":	"5"
"\217v":	"6"
"\217w":	"7"
"\217x":	"8"
"\217y":	"9"
$endif
#
$if term=kterm
"\e[\000":	""
$endif
#
$if term=mlterm
"\e[E":		re-read-init-file
"\eOH":		beginning-of-line
"\eOF":		end-of-line
"\e\eOH":	beginning-of-line
"\e\eOF":	end-of-line
"\e[1;2C":	forward-word
"\e[1;2D":	backward-word
"\e[1;2A":	history-search-backward
"\e[1;2B":	history-search-forward
"\e[1;3C":	forward-word
"\e[1;3D":	backward-word
"\e[1;3A":	history-search-backward
"\e[1;3B":	history-search-forward
"\e[1;4C":	forward-word
"\e[1;4D":	backward-word
"\e[1;4A":	history-search-backward
"\e[1;4B":	history-search-forward
"\e[1;5C":	forward-word
"\e[1;5D":	backward-word
"\e[1;5A":	history-search-backward
"\e[1;5B":	history-search-forward
"\e[1;6C":	forward-word
"\e[1;6D":	backward-word
"\e[1;6A":	history-search-backward
"\e[1;6B":	history-search-forward
"\e[1;7C":	forward-word
"\e[1;7D":	backward-word
"\e[1;7A":	history-search-backward
"\e[1;7B":	history-search-forward
"\e[1;8C":	forward-word
"\e[1;8D":	backward-word
"\e[1;8A":	history-search-backward
"\e[1;8B":	history-search-forward
"\e[11;2~":	""
"\e[12;2~":	""
"\e[13;2~":	""
"\e[14;2~":	""
"\e[15;2~":	""
"\e[17;2~":	""
"\e[18;2~":	""
"\e[19;2~":	""
"\e[20;2~":	""
"\e[21;2~":	""
"\e[23;2~":	""
"\e[24;2~":	""
"\e[11;3~":	""
"\e[12;3~":	""
"\e[13;3~":	""
"\e[14;3~":	""
"\e[15;3~":	""
"\e[17;3~":	""
"\e[18;3~":	""
"\e[19;3~":	""
"\e[20;3~":	""
"\e[21;3~":	""
"\e[23;3~":	""
"\e[24;3~":	""
"\e[11;4~":	""
"\e[12;4~":	""
"\e[13;4~":	""
"\e[14;4~":	""
"\e[15;4~":	""
"\e[17;4~":	""
"\e[18;4~":	""
"\e[19;4~":	""
"\e[20;4~":	""
"\e[21;4~":	""
"\e[23;4~":	""
"\e[24;4~":	""
"\e[11;5~":	""
"\e[12;5~":	""
"\e[13;5~":	""
"\e[14;5~":	""
"\e[15;5~":	""
"\e[17;5~":	""
"\e[18;5~":	""
"\e[19;5~":	""
"\e[20;5~":	""
"\e[21;5~":	""
"\e[23;5~":	""
"\e[24;5~":	""
"\e[11;6~":	""
"\e[12;6~":	""
"\e[13;6~":	""
"\e[14;6~":	""
"\e[15;6~":	""
"\e[17;6~":	""
"\e[18;6~":	""
"\e[19;6~":	""
"\e[20;6~":	""
"\e[21;6~":	""
"\e[23;6~":	""
"\e[24;6~":	""
"\e[11;7~":	""
"\e[12;7~":	""
"\e[13;7~":	""
"\e[14;7~":	""
"\e[15;7~":	""
"\e[17;7~":	""
"\e[18;7~":	""
"\e[19;7~":	""
"\e[20;7~":	""
"\e[21;7~":	""
"\e[23;7~":	""
"\e[24;7~":	""
"\e[11;8~":	""
"\e[12;8~":	""
"\e[13;8~":	""
"\e[14;8~":	""
"\e[15;8~":	""
"\e[17;8~":	""
"\e[18;8~":	""
"\e[19;8~":	""
"\e[20;8~":	""
"\e[21;8~":	""
"\e[23;8~":	""
"\e[24;8~":	""
$endif
#
$if term=rxvt-unicode
"\e[23$":	""
"\e[24$":	""
"\e[11^":	""
"\e[12^":	""
"\e[13^":	""
"\e[14^":	""
"\e[15^":	""
"\e[17^":	""
"\e[18^":	""
"\e[19^":	""
"\e[20^":	""
"\e[21^":	""
"\e[23^":	""
"\e[24^":	""
"\eOo":		"/"
"\eOj":		"*"
"\eOm":		"-"
"\eOk":		"+"
"\eOl":		","
"\eOM":		accept-line
"\eOn":		"."
"\eOp":		"0"
"\eOq":		"1"
"\eOr":		"2"
"\eOs":		"3"
"\eOt":		"4"
"\eOu":		"5"
"\eOv":		"6"
"\eOw":		"7"
"\eOx":		"8"
"\eOy":		"9"
"\e\eOo":	""
"\e\eOj":	""
"\e\eOm":	""
"\e\eOk":	""
"\e\eOl":	delete-char
"\e\eOM":	accept-line
"\e\eOn":	delete-char
"\e\eOp":	yank
"\e\eOq":	end-of-line
"\e\eOr":	next-history
"\e\eOs":	history-search-forward
"\e\eOt":	backward-char
"\e\eOu":	re-read-init-file
"\e\eOv":	forward-char
"\e\eOw":	beginning-of-line
"\e\eOx":	previous-history
"\e\eOy":	history-search-backward
"\eOc":		forward-word
"\eOd":		backward-word
"\eOa":		history-search-backward
"\eOb":		history-search-forward
"\e[c":		forward-word
"\e[d":		backward-word
"\e[a":		history-search-backward
"\e[b":		history-search-forward
"\e\e[c":	forward-word
"\e\e[d":	backward-word
"\e\e[a":	history-search-backward
"\e\e[b":	history-search-forward
"\e\e[C":	forward-word
"\e\e[D":	backward-word
"\e\e[A":	history-search-backward
"\e\e[B":	history-search-forward
"\e[2^":	yank
"\e[3^":	delete-char
"\e[5^":	history-search-backward
"\e[6^":	history-search-forward
"\e[7^":	beginning-of-line
"\e[8^":	end-of-line
"\e[2$":	yank
"\e[3$":	delete-char
"\e[5$":	history-search-backward
"\e[6$":	history-search-forward
"\e[7$":	beginning-of-line
"\e[8$":	end-of-line
"\e\e[2$":	yank
"\e\e[3$":	delete-char
"\e\e[5$":	history-search-backward
"\e\e[6$":	history-search-forward
"\e\e[7$":	beginning-of-line
"\e\e[8$":	end-of-line
"\e=":		accept-line
# Shift+Ctrl+(Alt+)KP_<0...9> generates
# \000 ... \011 (^@ upto TAB) we ignore these
$endif
#
# Screen
#
$if term=screen
"\e[1;2D":	backward-word
"\e[1;2C":	forward-word
"\e[1;2A":	previous-history
"\e[1;2B":	next-history
"\e[1;2H":	beginning-of-line
"\e[1;2F":	end-of-line
"\e[2;2~":	yank
"\e[3;2~":	delete-char
"\e[5;2~":	history-search-backward
"\e[6;2~":	history-search-forward
"\e[1;5D":	backward-word
"\e[1;5C":	forward-word
"\e[1;5A":	previous-history
"\e[1;5B":	next-history
"\e[1;5H":	beginning-of-line
"\e[1;5F":	end-of-line
"\e[2;5~":	yank
"\e[3;5~":	delete-char
"\e[5;5~":	history-search-backward
"\e[6;5~":	history-search-forward
"\e[1;3D":	backward-word
"\e[1;3C":	forward-word
"\e[1;3A":	previous-history
"\e[1;3B":	next-history
"\e[1;3H":	beginning-of-line
"\e[1;3F":	end-of-line
"\e[2;3~":	yank
"\e[3;3~":	delete-char
"\e[5;3~":	history-search-backward
"\e[6;3~":	history-search-forward
#
"\e[1;2P":	""
"\e[1;2Q":	""
"\e[1;2R":	""
"\e[1;2S":	""
"\e[15;2~":	""
"\e[17;2~":	""
"\e[18;2~":	""
"\e[19;2~":	""
"\e[20;2~":	""
"\e[21;2~":	""
"\e[23;2~":	""
"\e[24;2~":	""
#
"\e[1;5P":	""
"\e[1;5Q":	""
"\e[1;5R":	""
"\e[1;5S":	""
"\e[15;5~":	""
"\e[17;5~":	""
"\e[18;5~":	""
"\e[19;5~":	""
"\e[20;5~":	""
"\e[21;5~":	""
"\e[23;5~":	""
"\e[24;5~":	""
#
"\e[1;3P":	""
"\e[1;3Q":	""
"\e[1;3R":	""
"\e[1;3S":	""
"\e[15;3~":	""
"\e[17;3~":	""
"\e[18;3~":	""
"\e[19;3~":	""
"\e[20;3~":	""
"\e[21;3~":	""
"\e[23;3~":	""
"\e[24;3~":	""
$endif

My bash version is

$  bash --version
GNU bash, version 4.4.23(1)-release (x86_64-suse-linux-gnu)

So I downloaded bash-5.2.37 and followed the Linux From Scratch - Version r12.2-30 compilation guide and repeated the tests above, starting with empty .bashrc/.profile/.inputrc just to be sure.
Running

$ bash --version
GNU bash, version 5.2.37(1)-release (x86_64-pc-linux-gnu)
$ INPUTRC=~/.inputrc bash --noprofile --rcfile ~/.local/share/blesh/ble.sh

worked.
I then added a single line to .inputrc

$include /etc/inputrc.keys

and it broke my shell. I get the same errors as with the old bash versions.

To wrap this message up, I went and re-tested my claim above that with ~/.bash_profile, ~/.bash_login, and ~/.profile, files empty except ~/.bashrc containing

INPUTRC=~/.inputrc source ~/.local/share/blesh/ble.sh

ble.sh breaks when ~/.inputrc contains

set keymap emacs

and it turns out I was wrong in my message above. What breaks it is

$include /etc/inputrc.keys

EDIT:

Something interesting is happening with an empty ~/.bashrc/.profile/.bash_profile. If I start a fresh shell and run

INPUTRC=/dev/null source ~/.local/share/blesh/ble.sh

it breaks it in the same way I described above.
If I put the same line in my ~/.bashrc the shell works and ble is loaded.

EDIT2:
With both the new and old versions of bash everything works if I run/put in ~/.bashrc

INPUTRC=~/.inputrc bash --noprofile --rcfile ~/.local/share/blesh/ble.s

but fails with

INPUTRC=~/.inputrc source ~/.local/share/blesh/ble.sh

EDIT3:
It seems the line that breaks stuff from
/etc/inputrc.keys is

"\2331~":	beginning-of-line

in fact, any lines written in this style "\2will break ble.
I found-replaced all instances of "\2 with #\2" and everything works now.

My working patched setup is:

  • copy /etc/inputrc to /home/myuser/.inputrc,
  • copy /etc/.inputrc.keys to /home/myuser/.inputrc.keys,
  • replace any instance of $include /etc/.inputrc.keys with $include /home/myuser/.inputrc.keys, and
  • comment out/delete any line starting with "\2 in /home/myuser/.inputrc.keys

Beware! I had to specify the absolute path and not rely on ~ in ~/.inputrc!

@bitstreamout
Copy link

Leap 15.4 is an openSUSE clone from SLE-14-SP4 with some extensions

Thank you for the information. So, Leap is actually downstream of SLES. Then, we can guess SLES 15.3 and openSUSE Leap 15.3 have the old /etc/inputrc and /etc/inputrc.keys while SLES 15.4 and openSUSE Leap 15.4 have the fixed /etc/inputrc and etc/inputrc.keys. The reason that the openSUSE users wouldn't report the problem is probably because they can update it to the latest version of openSUSE for free (or they are just using Tumbleweed) while SLES servers are maintained for a long time without the major upgrade of the system.

In principle yes but my old Leap (which I should update yes) isn't a clean Leap 15.4 as well. The tcsh, bash, mutt, ... and many others are updated as I test the packages I maintain on my self 😉

@bitstreamout Do you think there is a possibility of backporting the fixed /etc/inputrc and /etc/inputrc.keys to the previous versions of SLES? With the current combination of an old Bash version and /etc/inputrc{,.keys}, the internal state of Readline is broken in an unrecoverable way. Even if one tries to overwrite the settings set up by the old /etc/inputrc{,.key}, the Readline doesn't seem to function correctly once the old /etc/inputrc{,.key} is loaded. Since /etc/inputrc{,.key} is (mostly) forcibly loaded in Bash sessions, there is no way for ble.sh to prevent Readline from being broken by /etc/inputrc{,.key}.

Principal yes ... ist should be noted that the bash and the libreadline are different packages and the bash on OpenSUSE as well on SLES uses the shared readline library from libreadline. Also the package aaa_base (which includes not only /etc/profile and /etc/bash.bashrc but also /etc/inputrc and (/usr)/etc/inputrc.keys)

@Migelo Which version of Bash does your system have? If possible, could you install the latest version of Bash in the system using a tarball or any other ways and test if the problem is worked around?

What really rankles me is that the SLE-15-SP3 had already an update for this as I see from the changelog of the package aaa_base as seen in my comment #424 (comment) and this was at 2021 ... and in this change the commit git-44-425f3e9b44ba9ead865d70ff6690d5f2869442dc.patch is mentioned which includes the commits from you

From ba286f5ea7666971887f42189cda2c667f3a8203 Mon Sep 17 00:00:00 2001
From: Koichi Murase <[email protected]>
Date: Sun, 21 Feb 2021 22:57:46 +0900
Subject: [PATCH 1/2] Fix keyseq specifications in /etc/inputrc{,.keys}
From ad4f96971956574db9b00c08e9b10093eeb22338 Mon Sep 17 00:00:00 2001
From: Koichi Murase <[email protected]>
Date: Sun, 21 Feb 2021 23:58:31 +0900
Subject: [PATCH 2/2] Comment out 8-bit C1 conflicting with UTF-8 in
 /etc/inputrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility External Problem/Bug Problems/Bugs of other projects
Projects
None yet
Development

No branches or pull requests

6 participants