In Ruby I have the following:
# Trap Interrupts
trap("INT") do
puts "Shutting down..."
exit
end
When I interrupt the program, the following is printed (Mac OSX Lion):
^CShutting down…
Is there any way to hide ^C from within Ruby?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Whether control characters are echoed is a property of the tty you’re using.
stty -echoctlis the Unix way to disable echoing of control characters. You can run this command from within your Ruby script and achieve the same effect if you’re using a Unix-ish system.