Command to be run when it is terminated by Ctrl+C
Is there a reserved command name that will be run when the entire script is terminated by the user with Control+c? For example, if I wanted to do puts "Script terminated by user." when the script is terminated, how can I do it?
trap("INT") do puts "Script terminated by user." exit end sleep 10
Run this, and hit ctrl-c.