Given the following Ruby program:
def getch
begin
system("stty raw -echo")
ch = STDIN.getc
puts "[#{ch}]"
ch
ensure
system("stty -raw echo")
end
end
print "Press a key: "
getch
puts "Have a nice day!"
and the following run:
$ ruby a.rb
Press a key: [t]
Have a nice day!
Why "Have a nice day!" is indented? Why the output is not like that:
$ ruby a.rb
Press a key: [t]
Have a nice day!
?
Ok, adding
opost
should fix it. Change you third line to look like this:I hope this is the answer you are looking for.