bug-bash
[Top][All Lists]
Advanced

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

read -e deletes extra characters


From: isabella parakiss
Subject: read -e deletes extra characters
Date: Tue, 24 Mar 2015 06:54:14 +0100

rlwrap is a nice utility that enables readline's features in utilities
that don't provide them.  I tried to rewrite something similar in bash
so here's a sketch of the code:

while read -re; do
  history -p -- "$REPLY"
  history -s -- "$REPLY"
done | ...


The problem is when I pipe that to a program that prints a prompt.
On a first impression, it seems to work fine, since pressing backspace
doesn't delete the printed prompt, but actually it will delete it if I
type some other character, then backspace.

In the examples, the prompt will be a $ and it will be printed by the
second program in the pipeline.

$<backspace><backspace><backspace>     # keeps the prompt
$x<backspace>                          # deletes both x and the prompt


I know that read has -p to print a prompt, and this seems to work if I
set read's prompt to any printable character.

read -e -p ' '
$ x<backspace>                         # deletes x, keeps space and $

read -e -p ''
$x<backspace>                          # deletes x and $


The same behaviour happens in all the versions from bash 3.

I think this is a bug, please fix it either by allowing an empty prompt
to read -p, or somehow disabling/removing the "feature" that deletes
extra characters that weren't typed by the user.

Thanks


---
xoxo iza



reply via email to

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