php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #29658 #!php with paramters is broken
Submitted: 2004-08-13 19:04 UTC Modified: 2004-08-14 12:15 UTC
From: xuefer at 21cn dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.3.8 OS: xp+cygwin &linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: xuefer at 21cn dot com
New email:
PHP Version: OS:

 

 [2004-08-13 19:04 UTC] xuefer at 21cn dot com
Description:
------------
touch php.ini

./test | grep php.ini

-i paramter works
but -c not

seems those spaces is not convert to '\0'

sapi/cli/php_cli.c

    while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0))!=-1) {
        switch (c) {
        case 'c':
            cli_sapi_module.php_ini_path_override = strdup(php_optarg);
/*debug*/
printf("%d %d '%s'\n", (int) php_optarg[0], strlen(php_opt_arg), php_optarg);
            break;
        case 'n':
            cli_sapi_module.php_ini_ignore = 1;
            break;
        }
    }


got "32 2 ' .'"


seems a problem of the shell

if -c is ok to be left broken.
-i shouldn't be working too

but allowing options in #! is very useful


Reproduce code:
---------------
#!/usr/bin/php -i -c .
// empty file


Expected result:
----------------
Configuration File (php.ini) Path => /etc/php.ini


Actual result:
--------------
Configuration File (php.ini) Path => ./php.ini


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-13 19:21 UTC] wez@php.net
#! is a unixy thing that is not supported on windows.
Additionally, most OS's don't support more than a single parameter there.
Not a PHP bug.
 [2004-08-14 05:01 UTC] xuefer at 21cn dot com
changed to feature request
updated os

how about:
#!/usr/bin/php -p "........"
p means parameters (or -o options)
and the string after it is parsed as command line options as shell do
 [2004-08-14 12:15 UTC] wez@php.net
Not a PHP problem.
Nothing we can do about it.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 09:01:28 2025 UTC