carlhuda/bundler — pull request #2478 by pjvds (2013-05-19 18:13:31+00:00)
Title: Fix succeeding error code for Thor failures

I'm automating a build pipeline and noticed that bundler exits with a succeeding exit code of `0` when a command is unknown. After digging the code of bundler I discovered that all `Thor::error`'s will result in a succeeding exit code.

# How to reproduce?
The simplest way to reproduce this error is executing the following command in your terminal:

bundle foobar
echo "Exit code: $?"

The output of this will be:

Could not find task "foobar"
Exit code: 0

# What did I change?
I [enabled the `THOR_DEBUG` flag](https://github.com/pjvds/bundler/commit/316a004d80a1c158284562d4cdded7e942fe673a). This will make thor raise errors when they occur instead of eating them. These errors are rescued in [friendly_errors.rb](https://github.com/pjvds/bundler/blob/7f8b1f751dfbc303525b9d2ff041d0e9f0f21920/lib/bundler/friendly_errors.rb).

# Which exit code did I pick, and why?
When bundler doesn't understand a switch, it exists with `15`, which is currently used for unknown tasks. This makes exit code `15` a general `unknown input` exit code.
Any other `Thor::error` should just exit with `1`, which indicates just a failure.

# Is there a failing test?
Yes, of course. I have added a test in this commit: [Add spec for exitstatus for unrecognized tasks](https://github.com/pjvds/bundler/commit/fafac675da80590adeb4d030e4a27a0236651e2a)

# Are there any braking changes?
Yes, bundler now always returns a non succeeding error code when a `Thor::error` is thrown. It exists with `15` when an `Thor::UndefinedCommandError` is raised and `1` for general `Thor:error`'s.