bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read -ed $'\r' messes up Enter key at the prompt


From: Stephane Chazelas
Subject: read -ed $'\r' messes up Enter key at the prompt
Date: Fri, 26 Apr 2019 15:09:05 +0100
User-agent: NeoMutt/20171215

One can use:

    IFS= read -i "$var" -red $'\r' var

In bash as the equivalent of zsh's

    vared var


To edit the content of a variable (with the added restriction
that $var can't contain CR or NUL characters), using ^V^J to
embed newline characters.

But I find that after I run that command and return to the
prompt, pressing Enter inserts ^M instead of accepting the
current line. It seems it only happens with -d $'\r'

$ INPUTRC=/dev/null ./bash --norc
bash-5.0$ echo "$BASH_VERSION"
5.0.7(3)-maint
bash-5.0$ IFS= read -i "$var" -red $'\r' var
foo
bash-5.0$ echo "$var"^M^M^M^M^M

(those ^M resulting of me pressing Enter as many times. I can
accept the current line by pressing Ctrl+J).

That's on GNU/Linux amd64 with the current git head. Same in 4.4.19.

Another related issue with read -ed ''

bash-5.0$ IFS= read -rep 'prompt> ' -d '' var
prompt> asd
prompt> qwe
prompt>
bash-5.0$ echo "$var"
asdqwe

Entering ^@ doesn't end the "read" but instead reissues a prompt
for more until I enter ^@ on an empty input.

It may also be worth documenting that the argument to -d cannot
be a multi-byte character, or that only the first byte (not
character) of the argument is taken as delimiter.

-- 
Stephane



reply via email to

[Prev in Thread] Current Thread [Next in Thread]