Ctrl-C to echo ^C or not
I've noticed that in some distributions, or even some versions of distributions, pressing Ctrl-C at the bash command prompt either results in ^C being echoed, or not. I've been looking in "man bash" for a setting that would affect that (it doesn't apply when outside of bash, so I presume it is just something bash does or has set) but cannot find it. Anyone know what to do in bash to change this? If it matters, I want to turn it off where it is on.
|
I think this behavior can be controlled with the stty command. Perhaps there is something in the bash startup scripts that is toggling an option.
Cheers, Evo2. |
Quote:
Code:
c@CW8:~$ while true; do sleep 1; done |
I just tried running bash under strace to see if bash (or some library linked into its process) was really the culprit. See the 6th line:
Code:
read(0, 0x7fffddc44e9f, 1) = ? ERESTARTSYS (To be restarted) |
Quote:
If you hit ctrl-C on the bash command line, however, it is bash's readline code that will echo "^C". This is new bash behavior was introduced in bash 4.0. In bash 4.1, a setting was added to control this readline feature: "echo-control-characters". So putting "set echo-control-characters off" in your .inputrc file will suppress "^C" echo on the bash command line (if using bash 4.1 or later). -Joe |
Welcome to LQ lavajoe :)
Thank you for the very lucid and complete explanation. |
All times are GMT -5. The time now is 04:48 AM. |