Req #80996 [NEW]: CLI Make '-B' incompatible with '-r' and <file>

From: Date: Tue, 27 Apr 2021 15:20:40 +0000
Subject: Req #80996 [NEW]: CLI Make '-B' incompatible with '-r' and <file>
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233593@lists.php.net to get a copy of this message
From:             mdw_php dot net at de-weerd dot name
Operating system: Debian/Windows
PHP version:      7.4.16
Package:          Unknown/Other Function
Bug Type:         Feature/Change Request
Bug description:CLI Make '-B' incompatible with '-r' and <file>

Description:
------------
Make '-B' and '-E' CLI options compatible with the '-r' and
'<file>'
arguments.

Only '-R' and '-F' options should imply that the CLI expects input.

This is usefull to run some code settings before the main script to
enable some options (-B "define('DEBUG_CLASS','1')" for instance).

Test script:
---------------
Running 
   php -B 'echo 1;' -r 'echo 0;'
Returns
   Either execute direct code, process stdin or use a file.

Running (with 'test.php' containing '<? echo 0;'
   php -B 'echo 1;' test.php

Expects input were 'php test.php' does not .


On a side note, 
   echo | php -B 'echo 1;' -R 'echo 0;'


Expected result:
----------------
PHP runs the code specified in '-B' and '-E' would be run around any
other code, either specified through '-r', '-R', '<file>'.

Currently '-B' seems to imply that input should be parsed, but IMHO only
'-R' (and -F) should imply that.

To compare with perl:
  perl -e 'BEGIN{print 1;} print 0;'

will print 10 and exit.

and 
  perl -e 'BEGIN{print 1;} print 0;' -p

will print 1 at the start and 0 for every input line.

The presence of "BEGIN" does not imply a loop.  



-- 
Edit bug report at https://bugs.php.net/bug.php?id=80996&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=80996&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=80996&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=80996&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=80996&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=80996&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=80996&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=80996&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=80996&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=80996&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=80996&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80996&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=80996&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=80996&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=80996&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=80996&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=80996&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=80996&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#233593) next »