ID: 36091 Comment by: ale at FreeBSD dot org Reported By: oli at isnic dot is Status: Assigned Bug Type: CGI related Operating System: FreeBSD 5.4 PHP Version: 5.1.2, 4.4.2 Assigned To: tony2001 New Comment:
Please *stop* saying shit, please! Your attitude towards FreeBSD is just stupid and all your bug database is pervaded by this arrogance; accusing FreeBSD for your coding deficiencies is incredibly childish. Even if you think so, Linux is not the OS reference and the 'optreset' variable existed *before* the birth of Linux and FreeBSD. This is taken from 4.3BSD: The variables opterr and optind are both initialized to 1. The optind variable may be set to another value before a set of calls to getopt() in order to skip over more or less argv entries. In order to use getopt() to evaluate multiple sets of arguments, or to evaluate a single set of arguments multiple times, the variable optreset must be set to 1 before the second and each additional set of calls to getopt(), and the variable optind must be reinitialized. The optreset variable was added to make it possible to call the getopt() function multiple times. Previous Comments: ------------------------------------------------------------------------ [2006-01-24 01:15:43] [EMAIL PROTECTED] Reassigned to myself. I'll commit the patch as soon as I figure out if it works on Solaris and AIX. ------------------------------------------------------------------------ [2006-01-20 13:30:34] [EMAIL PROTECTED] Changing optind re-initalization to optind = 1; fixes it for me on FreeBSD (and works on Linux). Though it still makes we wonder why FreeBSD prefers to have its own implementation of everything: for some reasons they also have `extern int optreset;`, but it doesn't make any difference whether you change it or not. ------------------------------------------------------------------------ [2006-01-20 11:31:09] [EMAIL PROTECTED] Ilia, this is propably some issue on FreeBSD, I can't reproduce with Linux. ------------------------------------------------------------------------ [2006-01-20 10:39:47] oli at isnic dot is Same result, I also tried with -n so that nothing was being taken from the php.ini, and again it works fine when compiled without the forementioned "fix" # cat t.php #!/usr/local/bin/php <?php $options = getopt("b:s"); var_dump($options); ?> # ./t.php -s -b 1 array(0) { } ------------------------------------------------------------------------ [2006-01-19 20:46:40] [EMAIL PROTECTED] This works just fine for me: test.php: #!sapi/cli/php <?php $options = getopt("b:s"); var_dump($options); ?> #./t.php -s -b 1 array(2) { ["s"]=> bool(false) ["b"]=> string(1) "1" } Works the same with both 5.1.2 and 4.4.2. Try this same script please. (change the hashbang path, of course :) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/36091 -- Edit this bug report at http://bugs.php.net/?id=36091&edit=1