Bug #18343 Updated: [RH Bug 68798] php command shell -c option parser and doco inaccurate

From: Date: Mon, 15 Jul 2002 21:56:21 +0000
Subject: Bug #18343 Updated: [RH Bug 68798] php command shell -c option parser and doco inaccurate
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14244@lists.php.net to get a copy of this message
ID: 18343 Updated by: edink@php.net Reported By: herrold@owlriver.com -Status: Open +Status: Bogus Bug Type: PHP options/info functions Operating System: Red Hat Linux 7.3, and Rawhide PHP Version: 4.2.1 New Comment: This is not a PHP bug. The problem is that most Unix kernels, including Linux have very limited shebang line processesing capabilities. Most standard Unix implemetations have limit of only 1 argument of 32 characters maximum. So #!/usr/bin/php -c /etc/php.ini cannot work on Linux. Previous Comments: ------------------------------------------------------------------------ [2002-07-15 17:41:52] herrold@owlriver.com The strace allowed me to see the bug --- This fails: [herrold@server3 herrold]$ head -50 ./birddaemon.php #!/usr/bin/php -c /etc/php.ini <?php // // test shim to show bug // // $db_server = "10.30.0.253"; $db_user = "root"; $db_passwd = "RedRedRobin"; $db_name = "birds"; // print "asdf"; // $link = mysql_connect($db_server, $db_user, $db_passwd) or die("Could not connect"); // $isdb = mysql_select_db($db_name) or die("Could not get database"); // $query = "update sightingstate set active = 'yes' where active = 'NULL"; $result = mysql_query($query); // exit ; // ?> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ This works: [herrold@server3 herrold]$ head -50 ./birddaemon.php #!/usr/bin/php -c/etc/ <?php // \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ At the end of the Red hat bugzilla initially quoted: Additional comment by herrold@owlriver.com 2002-07-14 15:08:09 WTF: bash-2.05a$ strace ./birddaemon.php 2>&1 | grep ini open(" /etc/php.ini/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory) read(3, "#!/usr/bin/php -c /etc/php.ini"..., 4096) = 492 bash-2.05a$ ------------------------------ php man page says: bash-2.05a$ man php No manual entry for php bash-2.05a$ =============================== http://www.php.net/manual/en/features.commandline.php says: -c <path>|<file> Look for php.ini file in this directory ahhh .... directory ... bash-2.05a$ joe ./birddaemon.php Processing '/etc/joe/joerc'...done Processing '/etc/joe/joerc'...done File ./birddaemon.php not changed so no update needed. bash-2.05a$ ./birddaemon.php X-Powered-By: PHP/4.2.1 Content-type: text/html asdf<br /> <b>Fatal error</b>: Call to undefined function: mysql_connect() in <b>/home/herrold/birddaemon.php</b> on line <b>13</b><br /> bash-2.05a$ strace ./birddaemon.php 2>&1 | grep ini open(" /etc//php.ini", O_RDONLY) = -1 ENOENT (No such file or directory) bash-2.05a$ bash-2.05a$ strace ./birddaemon.php 2>&1 | grep ini open(" /etc/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory) bash-2.05a$ ls -al /etc/php.ini -rw-r--r-- 1 root root 28245 Jul 14 14:48 /etc/php.ini bash-2.05a$ WTF ... it is not finding a file with a space becore the parsed option ... bash-2.05a$ strace ./birddaemon.php 2>&1 | grep ini open("/etc/php.ini", O_RDONLY) = 3 lstat64("/etc/php.ini", {st_mode=S_IFREG|0644, st_size=28245, ...}) = 0 bash-2.05a$ It found the file ... nasty ; d*mn HTML documentation -- two days of my life wasted ... ============================= try against earlier version: [herrold@server3 herrold]$ ./birddaemon.php X-Powered-By: PHP/4.1.2 Content-type: text/html asdf[herrold@server3 herrold]$ ======================================================== So it is REALLY a bad docs bug for MY form of invocation ... =================================== Notwithstanding, can a trim() please be applied to get rid of improper leading spaces in the option parser code for the command mode handler? -- Russ Herrold Additional comment by herrold@owlriver.com 2002-07-14 15:29:39 old subject: php command shell module inclusion through php.ini broken New subject: php command shell -c option parser and doco inaccurate ------------------------------------------------------------------------ [2002-07-15 17:33:01] edink@php.net No still not enough info. Are you talking about shebang line for your command line scripts? #!/usr/bin/php or command line like php -c ... ------------------------------------------------------------------------ [2002-07-15 17:01:21] herrold@owlriver.com If you cannot be bothered to click a link to see the details behind the Executive Summary, and your 'sniper' function is so hot to close a bug, I guess I wonder if you really want to fix the bug, or close the bug report. Your close itself is Bogus -- the cited URL does NOT begin suggest that you are unwilling to read reports with detail, summarized here. Indeed one strength of a web tracker is the ability to see the error in context. --------------------------- Since you cannot be bothers, here it is in summary form: 1. The option description for the -c option at: http://www.php.net/manual/en/features.commandline.php suggest that the interperter permits a space between the -c and the arguemnt -- It does NOT and the presence of such a space causes subtle errors (vis., it does not stat the file, and skips the -c option calue directory or file). ---------- 2. A trim() in the option parser leg on the object for the -c path will solve the problem. ---------- 00 -- specific enough? -- Russ herrold ------------------------------------------------------------------------ [2002-07-15 03:53:09] sniper@php.net Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PHP. ------------------------------------------------------------------------ [2002-07-14 21:07:34] herrold@owlriver.com I have 150 material lines of analysis of a doco bug in the php command shell option parser, and related doco at: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=68798 Executive Summary -- the PHP.NET web doco is inaccurate, and the option parser of the -c option needs to so a trim() on the option text before applying it. Failure to do so causes the load of the php.ini options to be skipped in the command line mode. This in turn causes subtle and hard to diagnose errors. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18343&edit=1

« previous php.bugs (#14244) next »