diff options
author | Ivan Mikheykin <ivan.mikheykin@flant.com> | 2020-01-17 22:26:35 +0300 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-01-27 13:32:19 +0100 |
commit | fd08f062ae5a3c92bfc0345da7e83ab320046864 (patch) | |
tree | 23ca98cfd88487284bfbf3536ad7d4c62c47008b /sapi/cli/php_cli.c | |
parent | b836d9cdc161c10d7c4b4eeb50ab123725967893 (diff) | |
download | php-git-fd08f062ae5a3c92bfc0345da7e83ab320046864.tar.gz |
Fix bug #78323: Code 0 is returned on invalid options
Set CLI exit code to 1 when invalid parameters are passed,
and print error to stderr.
Diffstat (limited to 'sapi/cli/php_cli.c')
-rw-r--r-- | sapi/cli/php_cli.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 3b053e223a..342c5e5feb 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -1265,7 +1265,7 @@ int main(int argc, char *argv[]) setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ #endif - while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2))!=-1) { + while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 1, 2))!=-1) { switch (c) { case 'c': if (ini_path_override) { @@ -1317,6 +1317,10 @@ int main(int argc, char *argv[]) case '?': php_cli_usage(argv[0]); goto out; + case PHP_GETOPT_INVALID_ARG: /* print usage on bad options, exit 1 */ + php_cli_usage(argv[0]); + exit_status = 1; + goto out; case 'i': case 'v': case 'm': sapi_module = &cli_sapi_module; goto exit_loop; |