shellsshexit-code

SSH does not return exit code of last command


I exexcute

$ ssh remotehost "exit 1"
$ echo $?
0

The result is 0 and not 1.

I have read here on stackoverflow, that it should be 1. What is going wrong? TIA!


Update (Solution):

ssh is a function on that site, and there is one command executed after the ssh call.

Executing /usr/bin/ssh remotehost "exit 1", the exit-code is 1.

Thanks to @jeb :)


Solution

  • Some hints to find such problems.