Bash print gets messed up after running script

bashterminalUbuntu

My bash terminal in Ubuntu gets messed up after running a Python script. I have no clue why but after that, I can't use it again and need to close the shell and open a new one.

I am attaching a picture for you to see. Maybe someone can point out what could be a reason for this to happen.

enter image description here

Best Answer

This usually happens when the script uses some commands to change terminal settings and fails to reset them back to their default before it ends.

For instance, you can simulate a situation such as this with this command:

stty -echo

(I expect it will look like what you're experimenting.)

You can typically get back to "normal" with the reset command, so try pressing Ctrl+C or Return to make sure you're at the start of a new prompt, then type "reset" (you won't see anything) and Return and things might get back to normal:

reset

It's hard to tell what checkpoint_ps.py is doing that's leaving the terminal in a weird state... Though disabling terminal "echo" might be that... It's a common thing to do while asking for a password (so the password doesn't show up.) It looks from the output like "sudo" is getting involved, so I wouldn't expect checkpoint_ps.py would be messing with the terminal itself... But who knows, it's possible. If you find something in there that might be related to that, maybe ask a separate question about it so we can help you figure that out too.

Related Question