I'm writting a bash wrapper to learn some scripting concepts. The idea is to write a script in bash and set it as a user's shell at login.
I made a while loop that read
s and eval
s user's input, and then noticed that, whenever user typed CTRL + C
, the script aborted so the user session ends.
To avoid this, I trapped SIGINT
, doing nothing in the trap.
Now, the problem is that when you type CTRL + C
at half of a command, it doesn't get cancelled as one would do on bash - it just ignores CTRL + C
.
So, if I type ping stockoverf^Cping stackoverflow.com
, I get ping stockoverfping stackoverflow.com
instead of the ping stackoverflow.com
that I wanted.
Is there any way to do that?
#!/bin/bash
# let's trap SIGINT (CTRL + C)
trap "" SIGINT
while true
do
read -e -p "$USER - SHIELD: `pwd`> " command
history -s $command
eval $command
done
^C^A^K
and an empty line that wouldn't show in pure bash (just^C
), but it's better than nothing. Anyway, it would be awesome to not depend onxdotool
, and to avoid those extra markers - say, make it just like bash works. Anyway, I didn't get the rtfm invitation... What should debug show me? – Free