[PATCH] sane fix for "php -c" when users do it all wrong
| From: | Steph Fox | Date: | Wed, 14 Jun 2006 02:02:19 +0000 |
| Subject: | [PATCH] sane fix for "php -c" when users do it all wrong | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-24118@lists.php.net to get a copy of this message | ||
Please can someone either apply this or give me a good reason not to?
Diffs are against PHP_5_2. Please say if you need them specifically for other branches.
- Steph
Index: sapi/cgi/cgi_main.c =================================================================== RCS file: /repository/php-src/sapi/cgi/cgi_main.c,v retrieving revision 1.267.2.15.2.4 diff -u -r1.267.2.15.2.4 cgi_main.c --- sapi/cgi/cgi_main.c 3 Jun 2006 22:02:02 -0000 1.267.2.15.2.4 +++ sapi/cgi/cgi_main.c 13 Jun 2006 19:05:38 -0000 @@ -1047,6 +1047,10 @@ while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) { switch (c) { case 'c': + if (argc == php_optind || strchr(php_optarg, '-') != NULL) { + printf("You need to give the path to php.ini after -c.\n"); + exit(0); + } cgi_sapi_module.php_ini_path_override = strdup(php_optarg); break; case 'n': Index: sapi/cli/php_cli.c =================================================================== RCS file: /repository/php-src/sapi/cli/php_cli.c,v retrieving revision 1.129.2.13.2.3 diff -u -r1.129.2.13.2.3 php_cli.c --- sapi/cli/php_cli.c 3 Jun 2006 22:02:02 -0000 1.129.2.13.2.3 +++ sapi/cli/php_cli.c 13 Jun 2006 19:03:58 -0000 @@ -640,6 +640,11 @@ while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0))!=-1) { switch (c) { case 'c': + if (argc == php_optind || strchr(php_optarg, '-') != NULL) { + printf("You need to give the path to php.ini after -c.\n"); + exit_status = 1; + goto out_err; + } cli_sapi_module.php_ini_path_override = strdup(php_optarg); break; case 'n':
Index: sapi/cgi/cgi_main.c =================================================================== RCS file: /repository/php-src/sapi/cgi/cgi_main.c,v retrieving revision 1.267.2.15.2.4 diff -u -r1.267.2.15.2.4 cgi_main.c --- sapi/cgi/cgi_main.c 3 Jun 2006 22:02:02 -0000 1.267.2.15.2.4 +++ sapi/cgi/cgi_main.c 13 Jun 2006 19:05:38 -0000 @@ -1047,6 +1047,10 @@ while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) { switch (c) { case 'c': + if (argc == php_optind || strchr(php_optarg, '-') != NULL) { + printf("You need to give the path to php.ini after -c.\n"); + exit(0); + } cgi_sapi_module.php_ini_path_override = strdup(php_optarg); break; case 'n': Index: sapi/cli/php_cli.c =================================================================== RCS file: /repository/php-src/sapi/cli/php_cli.c,v retrieving revision 1.129.2.13.2.3 diff -u -r1.129.2.13.2.3 php_cli.c --- sapi/cli/php_cli.c 3 Jun 2006 22:02:02 -0000 1.129.2.13.2.3 +++ sapi/cli/php_cli.c 13 Jun 2006 19:03:58 -0000 @@ -640,6 +640,11 @@ while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0))!=-1) { switch (c) { case 'c': + if (argc == php_optind || strchr(php_optarg, '-') != NULL) { + printf("You need to give the path to php.ini after -c.\n"); + exit_status = 1; + goto out_err; + } cli_sapi_module.php_ini_path_override = strdup(php_optarg); break; case 'n':