On an Ubuntu machine:
$ php -v PHP 5.5.10-1~dotdeb.1 (cli) (built: Mar 6 2014 18:55:59) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with uopz v2.0.4, Copyright (c) 2014, by Joe Watkins <krakjoe@php.net> with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
My test.php file is simple:
<?php exit(1);
I would expect this php test.php || echo "error" command php test.php || echo "error" php test.php || echo "error" will show "error", but it will exit with status 0.
$ php test.php $ echo $? 0
But on the same machine, the same code, but not in the file, works as expected:
$ php -r "exit(1);" || echo "error" error
or
$ php -r "exit(1);" $ echo $? 1
On another machine (archlinux) with php:
PHP 5.5.13 (cli) (built: May 29 2014 05:46:58) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
All cases work as expected, even when the code is run from a file, the status code is 1.
This is a real problem because git is dependent on these status codes, and Jenkins and I cannot do this.
Could this be configuration related? I checked cli php.ini and did not find anything suspicious.