Skip to content

sapi/cli/php_cli.c: later -n and -c should supersede earlier ones - #25261

Open
orlitzky wants to merge 1 commit into
php:masterfrom
orlitzky:n-and-c-flag-precedence
Open

orlitzky wants to merge 1 commit into
php:masterfrom
orlitzky:n-and-c-flag-precedence

Conversation

@orlitzky

@orlitzky orlitzky commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

The -n and -c flags serve essentially the same purpose, to indicate which ini file should be used. The -c flag lets you name an ini file explicitly, while -n means that no ini file should be used.

Typically, argument parsers will override earlier occurrences of a flag with later ones. Later occurrences of -c do indeed override earlier -c flags, but if you specify -n after -c, the -n is essentially ignored; the ini file passed to -c is loaded anyway.

After updating ext/standard/tests/ini_info/php_ini_loaded_file.phpt to support TEST_PHP_EXTRA_ARGS, that test fails if the extra args include -c. In particular, it fails "make test". This commit updates the argument parser so that subsequent -n override any existing -c flags, fixing the tests.

See also:

@remicollet

Copy link
Copy Markdown
Member

I dont' think such a behavior change is acceptable for stable branches (but is fine for next)

@orlitzky
orlitzky changed the base branch from PHP-8.4 to master November 12, 2026 12:55
The "-n" and "-c" flags serve essentially the same purpose, to
indicate which ini file should be used. The -c flag lets you name an
ini file explicitly, while -n means that no ini file should be used.

Typically, argument parsers will override earlier occurrences of a
flag with later ones. Later occurrences of -c do indeed override
earlier -c flags, but if you specify -n after -c, the -n is
essentially ignored; the ini file passed to -c is loaded anyway.

After updating ext/standard/tests/ini_info/php_ini_loaded_file.phpt to
support TEST_PHP_EXTRA_ARGS, that test fails if the extra args include
-c. In particular, it fails "make test". This commit updates the
argument parser so that subsequent -n override any existing -c
flags, fixing the tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants