r/badcode •

[deleted by user]

[deleted] — view deleted post

0 Upvotes

88 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Mar 26 '19

[deleted] — view deleted comment

9

u/Tynach Mar 26 '19

Apparently, on ANSI terminals \r clears the line. That's what makes this bad code, it prints out things even if it shouldn't, then checks if it needs to print out something else instead - and if so, uses platform-dependent quirks to erase what was previously printed before printing the new thing it thinks it should print.

I don't think they missed the point, but it's true that it's not necessarily bad code... Just not portable, nor optimal.