bash 4 on linux doesn't like it
$SSH_CONNECTION could contain spaces
ditto
extract the branch name more accurately,

this could also extract detached branch