jifunks / botany

command line virtual plant buddy
ISC License
438 stars 32 forks source link

Prevent infinite loops when piping to botany #20

Closed Ensiss closed 6 years ago

Ensiss commented 6 years ago

Piping invalid data (anything that doesn't exit properly) to botany caused an infinite loop, since getch immediately returns -1 when the input is closed. This PR fixes the issue by raising an IOError exception when getch returns -1, which is then caught in the main loop and exits the program.

jifunks commented 6 years ago

I'd rather disallow piping of characters into botany at all if possible. It's not in the spirit of the game. (But this commit does look like it would fix the issue at hand)