caskroom/homebrew-cask — pull request #7895 by claui (2014-12-08 12:43:50+00:00)
Title: In `SystemCommand`, fix `success?` and `exit_status`

For the upcoming `brew cask search` by `name`, I’m going to have to invoke a `Cask::SystemCommand` with the option `:must_succeed => false` and then look at the exit status.

Like this:

```rb
result = Cask::SystemCommand.run(command, :must_succeed => false)
if (result.exit_status >= 2)
# …
else
# …
end
```

The issue is that the [`SystemCommand::Result#exit_status`](https://github.com/caskroom/homebrew-cask/blob/d2f041d9d4224c6ef4f087fd571146dc461eb601/lib/cask/system_command.rb#L61) method returns the whole [`Process::Status`](http://ruby-doc.org/core-1.8.7/Process/Status.html) object instead of a `Fixnum`.

As a workaround, I could have done `result.exit_status.exitstatus` but I think this would be very ugly.

### Cause

When invoking a `SystemCommand` with the option `:must_succeed => false`, the code in `SystemCommand` [feeds](https://github.com/caskroom/homebrew-cask/blob/d2f041d9d4224c6ef4f087fd571146dc461eb601/lib/cask/system_command.rb#L35) a `Process.Status` object to `SystemCommand::Result.new` instead of the `Fixnum` it expects.

### Impact

Apart from the usage in the upcoming PR, why didn’t this issue ever come up?

I think this is because:

1. Usually, everyone uses `:must_succeed => true` so there is no need to care about `exit_status`, and

2. In the rare usages of `:must_succeed => false` (only the Casks `private-eye` and `soundflower` do this), no one cares about `exit_status`.

### Please review

Pinging @federicobond @ndr-qef @phinze @rolandwalker to ask if one of you could please have a look. Thanks! :blush: