Vim is a great text editor for unix systems, but it's notorious for being difficult to exit.
Write a full program that will output
:q to exit Vim. It should then read a single line of input, as it will then either be given a bash prompt, in which case the exit was successful, or an error, in which case there are unsaved changes.
The bash prompt will be this:
While the error will be this:
E37: No write since last change (add ! to override)
Upon being given the bash prompt, the program's work is done, and it should not give any more output (except for whitespace).
Upon being given the error, your program should randomly (ie each possibility has a non-zero probability of being chosen) output
:q!, to exit without saving, or
:x, to save and exit.
This is code-golf so fewest bytes in each language wins!