php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14416 -q and -d command line options seem to negate each other
Submitted: 2001-12-10 18:00 UTC Modified: 2002-04-08 05:44 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: andy at petdance dot com Assigned:
Status: Not a bug Package: PHP options/info functions
PHP Version: 4.1.0 OS: Solaris 7
Private report: No CVE-ID: None
 [2001-12-10 18:00 UTC] andy at petdance dot com
It seems that -q and -d cannot exist on the same shebang line.  We're using PHP for standalone shell scripts (i.e. no thru the web server).  -q and -d seem to negate each other: Whichever comes first on the shebang line wins.

alester@flr4[~]$ cat qd
#!/usr/src/php-4.1.0RC4/php -q -dinclude_path=.:../../Class:../../Include
<?php
print "include_path=";
print ini_get("include_path");
print "\n";
?>
alester@flr4[~]$ ./qd
include_path=.

# The -q works, since we have no headers, but the include_path isn't changed.

alester@flr4[~]$ cat dq
#!/usr/src/php-4.1.0RC4/php -dinclude_path=.:../../Class:../../Include -q
<?php
print "include_path=";
print ini_get("include_path");
print "\n";
?>
alester@flr4[~]$ ./dq
Content-type: text/html

include_path=.:../../Class:../../Include
alester@flr4[~]$

# The include path is changed, but now we have the Content-type header that -q should suppress.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-11 04:24 UTC] cardinal@php.net
Does this happen with the released PHP 4.1.0?

I don't have the RC handy, but I can't reproduce (On linux)
with 4.0.6 or 4.1.0

$ php410 -q -dinclude_path=.:../../Class:../../Include
<? echo ini_get('include_path') . "\n" ?>
.:../../Class:../../Include
$ php410 -dinclude_path=.:../../Class:../../Include -q
<? echo ini_get('include_path') . "\n" ?>
.:../../Class:../../Include


 [2001-12-11 13:28 UTC] andy at petdance dot com
Yes, it still fails under the brand new 4.1.0

alester@flr4[~]$ cat dq
#!/usr/local/bin/php -dinclude_path=.:../../Class:../../Include -q
<?php
print "PHP version=".phpversion()."\n";
print "include_path=".ini_get("include_path")."\n";
?>


alester@flr4[~]$ cat qd
#!/usr/local/bin/php -q -dinclude_path=.:../../Class:../../Include
<?php
print "PHP version=".phpversion()."\n";
print "include_path=".ini_get("include_path")."\n";
?>


Results are still the same:
# ignores the -q
alester@flr4[~]$ ./dq
Content-type: text/html

PHP version=4.1.0
include_path=.:../../Class:../../Include

# ignores the -d
alester@flr4[~]$ ./qd
PHP version=4.1.0
include_path=.

 [2002-04-03 18:00 UTC] zeekamotay at hotmail dot com
I'm using v4.1.2 on Linux, and I'm seeing the same issue.

It is not related specifically to -q and -d, but the number of options specified. If more than one option is specified (regardless of which), then _none_ of them will work.

This script works fine:

#!/usr/local/bin/php -dregister_globals
<?= "$PWD\n" ?>

But as soon as you add any character to the end of the shebang line, it fails. Also, -d options must _not_ have a space between the d and the option name. I.e, "-dregister_globals" works but "-d register_globals" does not.
 [2002-04-08 05:44 UTC] edink@php.net
This is an OS limitation. On most unix systems shebang line is limited to one option and on some to 32 characters only. The only OS that I know this works on is FreeBSD.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 07 14:01:28 2024 UTC