-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Fixed exit code for exceptions with error code 0 #8183
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
Conversation
@@ -116,7 +116,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null | |||
} | |||
$statusCode = $e->getCode(); | |||
|
|||
$statusCode = $statusCode ? (is_numeric($statusCode) ? (int) $statusCode : 1) : 0; | |||
$statusCode = $statusCode ? (is_numeric($statusCode) ? (int) $statusCode : 1) : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write this as is_numeric($statusCode) && $statusCode ? (int) $statusCode : 1;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what it used to be before symfony/console@fcbb61c and I had no idea why it changed. Any idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was missing the integer cast. And I confused this exception code with the normal status code of a command return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated and re-ran tests. Everything seems to be in order now.
On Mon, Jun 3, 2013 at 4:22 PM, Tobias Schultze [email protected]:
In src/Symfony/Component/Console/Application.php:
@@ -116,7 +116,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
}
$statusCode = $e->getCode();
$statusCode = $statusCode ? (is_numeric($statusCode) ? (int) $statusCode : 1) : 0;
$statusCode = $statusCode ? (is_numeric($statusCode) ? (int) $statusCode : 1) : 1;
It was missing the integer cast. And I confused this exception code with
the normal status code of a command return value.—
Reply to this email directly or view it on GitHubhttps://github.com//pull/8183/files#r4500339
.
Thanks for fixing. This should be merged into 2.1 as I've done it wrong there. |
Can someone redo the travis build please? It failed because of the stopwatch. |
merged in 2.1 |
@@ -116,7 +116,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null | |||
} | |||
$statusCode = $e->getCode(); | |||
|
|||
$statusCode = $statusCode ? (is_numeric($statusCode) ? (int) $statusCode : 1) : 0; | |||
$statusCode = is_numeric($statusCode) && $statusCode ? (int) $statusCode : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized this is still wrong. When $e->getCode();
returns 0.1
, it will still return 0 as exit code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is not a use case we need to support. getCode should return an integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to support that because getCode() can return mixed. This is why the is_numeric
check is there at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created #8202
- Prevent negative and 0 exit code from being used on exception - Prevent 255+ exit code from being used Fixes symfony#8183, symfony#8202
This PR was merged into the 2.1 branch. Discussion ---------- [Console] fix status and exit code Fix symfony#8183 (comment) and http://www.php.net/manual/en/function.exit.php > Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. The status 0 is used to terminate the program successfully. Commits ------- 6b9180a [Console] ensure exit code between 0-254 445b2e3 [Console] fix status code when Exception::getCode returns something like 0.1
Covers #8180