Unrecognised commands yields exit code 0
Summary
If I give sf a bogus command, it reports success exit code 0.
Steps To Reproduce
$ sf invalid < /dev/null; echo "Exit code: $?"
› Warning: invalid is not a sf command.
Did you mean env list? [y/n]: Exit code: 0
Expected result
I expect a non-zero exitcode to indicate a failure, e.g. since I have a typo for the command name in my script.
Actual result
The command purports to have succeeded. This is not ideal for example in a CI environment, as it may be considered a false positive.
System Information
{
"architecture": "darwin-arm64",
"cliVersion": "@salesforce/cli/2.33.3",
"nodeVersion": "node-v18.19.1",
"osVersion": "Darwin 23.4.0",
"rootPath": "/Users/XXX/node_modules/@salesforce/cli",
"shell": "bash",
"pluginVersions": [
"@oclif/plugin-autocomplete 3.0.13 (core)",
"@oclif/plugin-commands 3.2.0 (core)",
"@oclif/plugin-help 6.0.18 (core)",
"@oclif/plugin-not-found 3.0.14 (core)",
"@oclif/plugin-plugins 4.3.5 (core)",
"@oclif/plugin-search 1.0.20 (core)",
"@oclif/plugin-update 4.2.0 (core)",
"@oclif/plugin-version 2.0.14 (core)",
"@oclif/plugin-warn-if-update-available 3.0.14 (core)",
"@oclif/plugin-which 3.1.4 (core)",
"@salesforce/analytics 1.4.8 (link) /Users/XXX/node_modules/@salesforce/analytics",
"@salesforce/cli 2.33.3 (core)",
"apex 3.0.30 (core)",
"auth 3.3.23 (core)",
"community 3.0.27 (link) /Users/XXX/node_modules/@salesforce/plugin-community",
"data 3.1.9 (core)",
"deploy-retrieve 3.2.31 (core)",
"info 3.0.31 (core)",
"limits 3.1.13 (core)",
"marketplace 1.0.27 (core)",
"org 3.4.3 (core)",
"packaging 2.1.12 (core)",
"schema 3.1.7 (core)",
"settings 2.0.31 (core)",
"sobject 1.1.18 (core)",
"source 3.1.20 (core)",
"telemetry 3.1.16 (core)",
"templates 56.0.21 (core)",
"trust 3.3.16 (core)",
"user 3.3.3 (core)"
]
}
Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.
I called this out on #2739 -- the behavior is different in a TTY environment from a non-TTY environment. In a TTY environment, you get a nonzero exit code .. but a non-TTY environment it's 0
Agreed it sounds like a bug but it's been like this forever so it would be a breaking change.
Thanks for linking it, David. Closing as dup