Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fstack-protector-strong -Wformat
-Werror=format-security -Wall
uname output: Linux debvirt 6.0.0-2-amd64 #1 SMP PREEMPT_DYNAMIC Debian
6.0.5-1 (2022-10-28) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.2
Patch Level: 2
Release Status: release
Description:
When read -e is bound to tabulation
i.e. bind -x '"\C-i": "function"'
it is not possible to validate the entry after the first iteration.
It is possible to validate by pressing Ctrl-j, but that is not
a viable solution.
I tried to bind 'RETURN: "\C-j"' but that does not work.
It is not a new behavior in 5.2, but since then I used to work
around this issue with
read -set .001 -d '' DISCARD
before the actual read -e
Alas, this does not work anymore with 5.2 (-e and -t
combination triggers shell exit or, when used in a script, prevents
further use of read -e).
Is there a solution to this problem? The return of the previous
behavior of -e and -t combination would be fine for me although I don't
understand why I need this.
Below is an example to reproduce the problem.
Thanks.
Repeat-By:
#!/usr/bin/env bash
_comp() {
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
read -d '' -ra COMPREPLY < <(echo "$cur$RANDOM")
return 0
}
f_complete() {
declare COMPLETE COMP_LINE IFS=$' \t\n'
declare -a COMP_WORDS
declare -i COMP_CWORD COMP_POINT
COMP_LINE="${PROGNAME:-dummy} $READLINE_LINE"
COMP_POINT=${#COMP_LINE}
read -d '' -ra COMP_WORDS <<<"$COMP_LINE"
[[ "${COMP_LINE: -1}" == [[:blank:]] ]] && COMP_WORDS+=( "" )
(( COMP_CWORD=${#COMP_WORDS[@]} - 1 ))
_comp
COMPLETE="${COMPREPLY[0]} "
READLINE_LINE="${COMP_WORDS[*]:1:(( ${#COMP_WORDS[@]} - 2 ))} $COMPLETE"
READLINE_LINE="${READLINE_LINE# }"
READLINE_POINT="${#READLINE_LINE}"
return 0
}
set -o emacs
bind -x '"\C-i": "f_complete"'
while true; do
### 'read -e -t' used to solve the issue but not anymore in Bash 5.2
### (at least 5.2.2(1)-release (x86_64-pc-linux-gnu))
#read -set .001 -d '' DISCARD
read -e -p "entry> " ENTRY ### use TAB completion here
sleep .2; echo "you typed $ENTRY"
done