Hi,
I currently work on a daemon implemented in PHP and as such, I want to keep
all configurations in place while the php binary can be used by other cli
scripts with the default /etc/php.ini file. I could recompile PHP and add a
new folder to the folder which is scanned for php.ini files. A better idea
would be a configuration with the shebang like this:
#!/usr/local/php/bin/php -c /var/www/php.ini
Unfortunately, this doesn't work on Linux due to a <del>bug</del>
<ins>feature</ins> which keeps the shebang parameters as one string on
argv[1]. There is already a ticket for this problem:
https://bugs.php.net/bug.php?id=53034
My specific problem could be tackled in two ways:
- Scan "." every time cli is called for a php.ini file or
- Try to make argv interpretation more intelligent and parse/merge shebang
parameters.
The second solution, would also open the possebility to define constants or
make use of all other cli parameters. Well, there's also a quick hack. We
could change php_getopt() in order to make this a valid argument:
php -c=/var/www/php.ini
Anyway, I would provide a patch for the shebang parsing, but I wanted to
put out my feelers what you think about this idea in general. I know, it's
an OS problem, but we could work around this problem very quickly and
improve the usability of cli scripts alot.
Robert
My specific problem could be tackled in two ways:
- Scan "." every time cli is called for a php.ini file or
- Try to make argv interpretation more intelligent and parse/merge shebang
parameters.
There are |.user.ini files, but only for CGI/FastCGI
http://es2.php.net/manual/en/configuration.file.per-user.php
|
The second solution, would also open the possebility to define constants or
make use of all other cli parameters. Well, there's also a quick hack. We
could change php_getopt() in order to make this a valid argument:php -c=/var/www/php.ini
What's wrong with (currently working) php -c/var/www/php.ini ?
I've never gotten -d in shebang to work properly, I'd love to see that working.
-----Original Message-----
From: Ángel González [mailto:keisial@gmail.com]
Sent: Wednesday, January 25, 2012 6:00 PM
To: Robert Eisele
Cc: PHP internals
Subject: Re: [PHP-DEV] Shebang parsing
My specific problem could be tackled in two ways:
- Scan "." every time cli is called for a php.ini file or
- Try to make argv interpretation more intelligent and parse/merge
shebang parameters.
There are |.user.ini files, but only for CGI/FastCGI http://es2.php.net/manual/en/configuration.file.per-user.php
|
The second solution, would also open the possebility to define
constants or make use of all other cli parameters. Well, there's also
a quick hack. We could change php_getopt() in order to make this a valid argument:php -c=/var/www/php.ini
What's wrong with (currently working) php -c/var/www/php.ini ?
it has a length limit, if I remember correctly it is some reall short value
on linux.
it seems to be 127 character:
http://www.in-ulm.de/~mascheck/various/shebang/
2012/1/26 Clint M Priest cpriest@zerocue.com
I've never gotten -d in shebang to work properly, I'd love to see that
working.
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
Hi,
from
http://stackoverflow.com/questions/4303128/how-to-use-multiple-arguments-with-a-shebang-i-e
- Some operating systems simply treat the entire thing as the path.
After all, in most operating systems, whitespace or dashes
are legal in a
path.- Some operating systems split at whitespace and treat the first
part as the path to the interpreter and the rest as
individual arguments. - Some operating systems split at the first whitespace and
treat the front part as the path to the interpeter and the rest as a
single argument (which is what you are seeing). - Some even don't support shebang lines at all.
- Some operating systems split at whitespace and treat the first
Thankfully, 1. and 4. seem to have died out, but 3. is pretty widespread,
so you simply cannot rely on being able to pass more than one argument.
Devis
2012/1/26 Ferenc Kovacs tyra3l@gmail.com
it has a length limit, if I remember correctly it is some reall short value
on linux.
it seems to be 127 character:
http://www.in-ulm.de/~mascheck/various/shebang/2012/1/26 Clint M Priest cpriest@zerocue.com
I've never gotten -d in shebang to work properly, I'd love to see that
working.--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
Surely you can detect which operating system you're running on, and have
PHP act accordingly?
(Note: on my phone, haven't read the link!)
Kiall
Sent from my mobile - Sorry for being short.
Hi,
from
http://stackoverflow.com/questions/4303128/how-to-use-multiple-arguments-with-a-shebang-i-e
- Some operating systems simply treat the entire thing as the path.
After all, in most operating systems, whitespace or dashes
are legal in a
path.
- Some operating systems split at whitespace and treat the first
part as the path to the interpreter and the rest as
individual arguments.- Some operating systems split at the first whitespace and
treat the front part as the path to the interpeter and the rest as
a
single argument (which is what you are seeing).- Some even don't support shebang lines at all.
Thankfully, 1. and 4. seem to have died out, but 3. is pretty widespread,
so you simply cannot rely on being able to pass more than one argument.Devis
2012/1/26 Ferenc Kovacs tyra3l@gmail.com
it has a length limit, if I remember correctly it is some reall short
value
on linux.
it seems to be 127 character:
http://www.in-ulm.de/~mascheck/various/shebang/2012/1/26 Clint M Priest cpriest@zerocue.com
I've never gotten -d in shebang to work properly, I'd love to see that
working.--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
Surely you can detect which operating system you're running on, and have
PHP act accordingly?(Note: on my phone, haven't read the link!)
Kiall
It's probably not reliable. Note that a simple and completely reliable
solution
would be instead of having two files (php file + custom php.ini), to use a
third one as launcher:
#!/bin/sh
exec php -dextension=foo.so -c /path/to/myphp.ini /path/to/myfile.php
Some may also read the execve() linux man page.
It has hints about argument parsing and shebangs :)
http://linux.die.net/man/2/execve
Julien.P
2012/1/26 Ángel González keisial@gmail.com
Surely you can detect which operating system you're running on, and have
PHP act accordingly?(Note: on my phone, haven't read the link!)
Kiall
It's probably not reliable. Note that a simple and completely reliable
solution
would be instead of having two files (php file + custom php.ini), to use a
third one as launcher:#!/bin/sh
exec php -dextension=foo.so -c /path/to/myphp.ini /path/to/myfile.php