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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC