I did a `git bisect` and the change happened when we altered the way we executed SSH commands. We used to create a temporary script containing shell command and doing `cmd.add(tempCmdFile.getAbsolutePath());` which only worked with localhost, because we weren't copying the file across. It was altered to do  `"bash -c \"" + command + "\"";` where command is either the script, or a series of commands, but the `$` characters were not escaped, so we never got `$?` as the return code.

The reason for not calling `exit 123` is that this terminates the sequence of commands immediately, and I wanted to test the script content that sets `RESULT=$?` and returns it.