[php-src] PR #18583: Only quote `php --ini` values when out is a tty
| From: | schneems | Date: | Sun, 18 May 2025 00:47:21 +0000 |
| Subject: | [php-src] PR #18583: Only quote `php --ini` values when out is a tty | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-31701@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/18583
Author: schneems
A comment in #18527 mentioned that many scripts use
php—-ini to bootstrap information
about the system. Searching on GitHub confirms that many places will not work with quotes out of the
box: https://github.com/search?q=content%3A%22php%20--ini%22&type=code.
Many seem to be variants on this pattern
```
$ echo "extension=mongodb.so" >> php --ini | grep "Loaded
Configuration" | sed -e "s|.*:\s*||"
```
To preserve these existing scripts, we can detect when the output is a TTY to optionally quote them.
This is the new behavior:
Output is a tty:
```
$ make -j$(nproc) &> /dev/null && env
PHP_INI_SCAN_DIR="/opt/homebrew/etc/php/8.4/conf.d "
PHPRC="/opt/homebrew/etc/php/8.4" ./sapi/cli/php --ini
Configuration File (php.ini) Path: "/usr/local/lib"
Loaded Configuration File: "/opt/homebrew/etc/php/8.4/php.ini"
Scan for additional .ini files in: "/opt/homebrew/etc/php/8.4/conf.d "
Additional .ini files parsed: (none)
```
Output is not a tty:
```
$ make -j$(nproc) &> /dev/null && env
PHP_INI_SCAN_DIR="/opt/homebrew/etc/php/8.4/conf.d "
PHPRC="/opt/homebrew/etc/php/8.4" ./sapi/cli/php --ini | tee
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: /opt/homebrew/etc/php/8.4/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.4/conf.d
Additional .ini files parsed: (none)
```