fixed problems when pre-set PROMPT_COMMAND has trailing semi-colon

There was a problem on my Mac where the PROMPT_COMMAND is set to 'update_terminal_cwd; ' (with a trailing space and a trailing semi-colon. This triggers a syntax error on the resulting double semi-colon.
The two line remove all trailing spaces and then all trailing semi-colons