-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add $result_code parameter to shell_exec #7663
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
base: master
Are you sure you want to change the base?
Conversation
|
||
if (ret_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.
Won't this evaluate to false
if ret_code === 0
?
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.
If so, is exec
not also affected by this?
Lines 246 to 248 in 41d2785
if (ret_code) { | |
ZEND_TRY_ASSIGN_REF_LONG(ret_code, ret); | |
} |
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.
TL;DR: this code is fine.
[First, that's C not PHP, so there's no "===
" operator; second,] ret_code
is a zval *
i.e. a pointer to zval
, so if (ret_code)
means if (ret_code != NULL)
i.e. (here) the PHP function was called with a 2nd argument (a variable into which to copy the value of ret_pclose
).
This needs some tests. |
Sorry to reply here, I'm not subscribed to the mailing list yet, will fix that during the weekend. I added a 👎 because I think that adding referenced parameters adds confusion everywhere they are used. The feature is definitely useful, but I think it should be achieved in a different way, in a more "pure" (in terms of function). There are many options for that:
|
?> | ||
--EXPECT-- | ||
int(0) | ||
int(127) |
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.
isn't this 127 on unix-like OS's (Linux, MacOS, BSD),
but just 1 on Windows ? then again i wouldn't expect to find /bin/true
on Windows
it is possible to make /bin/true executable on windows tho:
C:\>mkdir bin
C:\>cd bin
C:\bin>copy C:\Windows\System32\PING.EXE .
1 file(s) copied.
C:\bin>move PING.EXE true.exe
1 file(s) moved.
C:\bin>php -r "var_dump(is_executable('/bin/true'));"
bool(false)
C:\bin>move true.exe true
1 file(s) moved.
C:\bin>php -r "var_dump(is_executable('/bin/true'));"
bool(true)
What's the status here? The respective RFC is still listed as being under discussion, although apparently there was no more discussion for quite a while. Are you planning to continue the RFC process for this feature, @l-pt? |
Actually, I don't see the point getting the result code with |
@cmb69: A point argued in https://bugs.php.net/bug.php?id=81493 was:
and https://externals.io/message/116439 added:
and I wonder if "Execute an external program" is really always identical to "Execute command via shell" (e.g. for shell builtins)? As for the backtick operator, it is explicitly said to remain unaffected. |
|
RFC: https://wiki.php.net/rfc/shell_exec_result_code_param