Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit with a correct exit code when outputting to the console #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Exit with a correct exit code when outputting to the console #98

wants to merge 1 commit into from

Conversation

anroots
Copy link

@anroots anroots commented Feb 28, 2016

Running the scan command and outputting the result to console would always exit with an exit code of 1 regardless of whether there were any errors found or not.

This messes up CI builds and other usages where the exit code is meaningful.

The bug was caused by invalid assumption in the result value of Output\Console::render: the $fail variable is an integer, not an array.

The following illustrates the previous situation and how using count always resulted in the exit code of 1.

php > $fail = 0;
php > var_dump((count($fail) > 0) ? 1 : 0);
int(1)
php > $fail = 1;
php > var_dump((count($fail) > 0) ? 1 : 0);
int(1)

This patch fixes the bug; Output\Console::render now treats the $fail variable as an integer and returns a correct exit status.

Running the Scan command and outputting the result to console
would always exit with an exit code of `1` regardless of whether
there were any errors found or not.

This messes up CI builds and other usages where the exit code is
meaningful.

The bug was caused by invalid assumption in the result value of
`Output\Console::render`: the `$fail` variable is an integer, not an array.

This patch fixes the bug; `Output\Console::render` now treats the
`$fail` variable as an integer and returns a correct exit status.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant