Check last error code across OS

From Terminal / Command Prompt, the return code from the last command is printed by:

  • Mac / Linux: echo $?
  • Windows command prompt: echo %errorlevel%
  • PowerShell: echo $lasterrorcode