php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71624 `php -R` (PHP_MODE_PROCESS_STDIN) is broken
Submitted: 2016-02-18 12:19 UTC Modified: 2016-03-13 03:23 UTC
From: dana at dana dot is Assigned: seander (profile)
Status: Closed Package: CGI/CLI related
PHP Version: 7.0.3 OS:
Private report: No CVE-ID: None
 [2016-02-18 12:19 UTC] dana at dana dot is
Description:
------------
It looks like between 5.6 and 7.0 somebody broke the CLI utility's `-R` option. Specifically:

* $argi is always 0

* $argn always has the last character cut off

I've confirmed it works as expected in PHP 5.6.14 on OS X, whilst it's broken in 7.0.2 on OS X and master on Ubuntu.

I'm not very good at C, so i don't have a patch, i'm sorry.

Test script:
---------------
% php -R 'echo "${argi}\n";' <<< $'foo\nbar'
% php -R 'echo "${argn}\n";' <<< $'foo\nbar'

Expected result:
----------------
% php --version | head -1
PHP 5.6.14 (cli) (built: Oct  3 2015 14:54:13)
% php -R 'echo "${argi}\n";' <<< $'foo\nbar'
1
2
% php -R 'echo "${argn}\n";' <<< $'foo\nbar'
foo
bar

Actual result:
--------------
% php --version | head -1
PHP 7.0.2 (cli) (built: Jan  7 2016 10:40:26) ( NTS )
proserpina:php % php -R 'echo "${argi}\n";' <<< $'foo\nbar'
0
0
proserpina:php % php -R 'echo "${argn}\n";' <<< $'foo\nbar'
fo
ba

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-13 03:23 UTC] seander@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: seander
 [2016-03-13 03:23 UTC] seander@php.net
Hi!

I opened a PR fixing this, would you mind trying it out and see if it works for you?

thanks for reporting
 [2016-03-15 06:12 UTC] ab@php.net
Automatic comment on behalf of sean@siobud.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=68ebfc87ad4f3842cd680c32ab307344c8659ce3
Log: Fix bug #71624, PHP_MODE_PROCESS_STDIN (CLI SAPI called with '-R') did not properly set $argi and $argn
 [2016-03-15 06:12 UTC] ab@php.net
-Status: Assigned +Status: Closed
 [2016-07-20 11:32 UTC] davey@php.net
Automatic comment on behalf of sean@siobud.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=68ebfc87ad4f3842cd680c32ab307344c8659ce3
Log: Fix bug #71624, PHP_MODE_PROCESS_STDIN (CLI SAPI called with '-R') did not properly set $argi and $argn
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC