Edit report at https://bugs.php.net/bug.php?id=63567&edit=1
ID: 63567
Comment by: circus2 at web dot de
Reported by: seld@php.net
Summary: exec() always yields a 1 return code
Status: Feedback
Type: Bug
Package: Program Execution
Operating System: Windows 7 x64
PHP Version: 5.5.0alpha1
Block user comment: N
Private report: N
New Comment:
I already tried it in CLI mode and I tried TS as well as NTS. I also played with
the php-cli.ini and also tried it without renaming the ini-files (fresh php
copies). Also played with the system path to add git / php and everything
involved.
Nothing changed. I believe it's a setting of my environment or some programm
hooked on the cmd.exe
I still get return code 1 and the syntax error - but the command is executed. Is
there any command i can use to cross check something.
Previous Comments:
------------------------------------------------------------------------
[2012-11-27 09:51:37] pajoye@php.net
@circus
ini settings won't affect anything in this area using cli.
Do you always use the TS version? Can you test only in CLI please and post the
result here?
------------------------------------------------------------------------
[2012-11-21 08:05:30] circus2 at web dot de
It's happening on a Win 7 Home Premium 64Bits running with PHP 5.4.8 VC9 x86
Thread Safe edition but I can reproduce it with every PHP (5.2, 5.3, 5.5alpha)
edition.
Unfortunately I have also this weird syntax error.
I have no clue what's going on. I also played with the php-cli.ini, with my system
path and so on.
------------------------------------------------------------------------
[2012-11-20 17:57:16] pajoye@php.net
Can't reproduce it here.
On which system or PHP version(s) does it happen exactly?
------------------------------------------------------------------------
[2012-11-20 16:19:56] seld@php.net
Description:
------------
Running exec() seems to detect a non-zero (and specifically 1) return code/exit code for the
process. No matter what process. It also affects the proc_open class of functions so there is not
even a decent workaround as far as we know.
Works on my machine but @johmue on github has the issue consistently. He tried with all latest 5.2,
5.3 and 5.4, even 5.5-alpha1. They all do the same. Yet on my machine 5.4.8 works fine. At first
sight I have exactly the same OS and PHP build that he does, so this makes no sense to me. There
must be something wrong in his environment but we are not able to figure out what causes it.
Note that trying the same thing in the shell directly yields a correct result, so the issue seems to
be in php, for example this works:
C:\>dir
[snip]
C:\>echo %errorlevel%
0
You can find the full thread below, but I tried to sum it up above:
https://github.com/composer/composer/issues/613
Test script:
---------------
C:\>php -r "exec('dir', $out, $ret);var_dump($ret);"
Expected result:
----------------
int(0)
Actual result:
--------------
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung
ist falsch.
int(1)
----
Interstingly, it does output the wrong return code, and also prints this warning saying that the
syntax of the filename/command is wrong.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63567&edit=1