hanslub42 / rlwrap

A readline wrapper
GNU General Public License v2.0
2.59k stars 151 forks source link

Can rlwrap catch SIGINT? #155

Closed nkh closed 2 years ago

nkh commented 2 years ago

running the man page example in a subshell

I use ^C to end the input, I get:

order=$(rlwrap -pYellow -S 'Your pizza? ' -H past_orders -P Margherita -o ./silent) Your pizza? Margherita

when I expect

order=$(rlwrap -pYellow -S 'Your pizza? ' -H past_orders -P Margherita -o ./silent)

hanslub42 commented 2 years ago

Yes, rlwrap does not erase the prompt and user input when it receives a SIGINT. Should it?

What is worse is that the terminal doesn't get reset to its original state when rlwrap is run in a subshell (like in your case) See #145

nkh commented 2 years ago

I not sure if it should or not, probably not since it can be done this way:

(trap 'echo -ne "\e[A\e[K"' SIGINT ; order=$(rlwrap -pYellow -S 'Your pizza? ' -o cat))