When login fails, the CLI exit with an error code (1). Apparently it doesn't do that in v2... in fact, it seems like other commands (uploading app package & deploying), when they fail, aren't existing with a non-zero return code.
When a CLI command fails, the CLI returns a non-zero exit code.
When a CLI command fails, the CLI returns a zero exit code, indicating the process completed successfully, even when the command fails.
I only checked three commands:
o365 logino365 spo app addo365 spo app deployNoticed this in my CI/CD automation. I use the CLI for uploading & deploying SharePoint packages to SPO. Everything was working fine until today when my deploy steps were hanging and eventually timing out.
Inspection of the logs traced back to a failed login as I was using the v1 vs newer v2 CLI syntax (*I was using the o365 spo login .. instead of o365 login ..), but the step wasn't failing. Steps fail in CD when they detect a non-zero exit code from the command.
The following image shows a failed login from the logs, BUT notice the green arrow where the task is not recognized as failing. I noticed the same thing where the upload step (o365 spo add app ...) was also failing in the logs, but the step wasn't seen as a failed step.

Another example from uploading & deploying an app package... notice the first one is even failing (node.js error) but green status text indicates the process was successful, same with the check in the top right.

Thanks for reporting it. This is definitely not intentional and the CLI should be returning non-zero exit codes when a command fails. One of the things that heavily relies on this capability is the Starter Kit provisioning script. I'll have a look at it asap to see if there are some edge cases that we might have missed. Sorry for the trouble.
When I run o365 spo login, you indeed get a 0 exit code. That is an error that we should fix, ie. CLI should return a non-zero code when trying to run non-existent commands.
When you run a command like o365 spo web get -u https://contoso.sharepoint.com, which leads to an error, you get a non-zero exit code, so this is correct.
I also noticed, that when you're not authenticated and try to run a command which requires it, instead of throwing an error, we're issuing a login prompt which shouldn't be the case. So it's another bug that slipped through our fingers.
Awesome... nice quick work!

...or not work when expected ;)
Exactly! 馃憤
Fixes are available in the latest beta which you can get @ @pnp/office365-cli@next. Once again thank you for spotting and reporting the issue 馃憤