]> granicus.if.org Git - php/commitdiff
continuation on bugfix #13757
authorShane Caraveo <shane@php.net>
Mon, 19 May 2003 06:46:19 +0000 (06:46 +0000)
committerShane Caraveo <shane@php.net>
Mon, 19 May 2003 06:46:19 +0000 (06:46 +0000)
make argv/argc *and* query_string work correctly when running cgi in shell

sapi/cgi/cgi_main.c

index 3125a46f2b9a011db3ba7f714a485eeff200fd36..d8503d1c074865510ce327ea4c19c3a1fc9ff26e 100644 (file)
@@ -1320,6 +1320,9 @@ consult the installation file that came with this distribution, or visit \n\
                                case 'f': /* parse file */
                                                script_file = estrdup(optarg);
                                                no_headers = 1;
+                                               /* arguments after the file are considered script args */
+                                               SG(request_info).argc = argc - (optind-1);
+                                               SG(request_info).argv = &argv[optind-1];
                                                break;
 
                                case 'g': /* define global variables on command line */
@@ -1415,6 +1418,9 @@ consult the installation file that came with this distribution, or visit \n\
                        }
 
                        if (!SG(request_info).path_translated && argc > optind) {
+                               /* arguments after the file are considered script args */
+                               SG(request_info).argc = argc - optind;
+                               SG(request_info).argv = &argv[optind];
                                /* file is on command line, but not in -f opt */
                                SG(request_info).path_translated = estrdup(argv[optind++]);
                        }
@@ -1428,7 +1434,7 @@ consult the installation file that came with this distribution, or visit \n\
                           test.php "v1=test&v2=hello world!"
                           test.php v1=test "v2=hello world!"
                        */
-                       if (!SG(request_info).query_string) {
+                       if (!SG(request_info).query_string && argc > optind) {
                                len = 0;
                                for (i = optind; i < argc; i++) {
                                        len += strlen(argv[i]) + 1;