[php-src] master: Fix visibility of whitespace in config output (#18527)

From: Date: Sun, 11 May 2025 14:04:50 +0000
Subject: [php-src] master: Fix visibility of whitespace in config output (#18527)
Groups: php.cvs 
Request: Send a blank email to [email protected] to get a copy of this message
Author: Richard Schneeman (schneems)
Committer: GitHub (web-flow)
Pusher: Girgias
Date: 2025-05-11T14:53:56+01:00

Commit: https://github.com/php/php-src/commit/331ac35f5802145648fefa6312aa54c7306b93d6
Raw diff: https://github.com/php/php-src/commit/331ac35f5802145648fefa6312aa54c7306b93d6.diff

Fix visibility of whitespace in config output (#18527)

When a config var has whitespace (especially trailing whitespace) it is hard to see. This commit
wraps the values (if they exist) in double quotes, so the difference is visually observable:

Before:

```
$ export PHP_INI_SCAN_DIR="/opt/homebrew/etc/php/8.4/conf.d         "
$ ./sapi/cli/php --ini
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File:         /opt/homebrew/etc/php/8.4/conf.d         
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)
```

> Note 
> The above output has trailing whitespace that is not visible, you can see it if you copy it
> into an editor:

After:

```
$ ./sapi/cli/php --ini
Configuration File (php.ini) Path: "/usr/local/lib"
Loaded Configuration File:         "/opt/homebrew/etc/php/8.4/conf.d         "
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)
```

Above the whitespace is now visible /opt/homebrew/etc/php/8.4/conf.d         .

Close #18390

Changed paths:
  M  sapi/cli/php_cli.c


Diff:

diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 91dd0864c2fb..8a8f13895340 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -1106,9 +1106,17 @@ static int do_cli(int argc, char **argv) /* {{{ */
 
 		case PHP_CLI_MODE_SHOW_INI_CONFIG:
 			{
-				zend_printf("Configuration File (php.ini) Path: %s\n", PHP_CONFIG_FILE_PATH);
-				zend_printf("Loaded Configuration File:         %s\n", php_ini_opened_path ?
php_ini_opened_path : "(none)");
-				zend_printf("Scan for additional .ini files in: %s\n", php_ini_scanned_path  ?
php_ini_scanned_path : "(none)");
+				zend_printf("Configuration File (php.ini) Path: \"%s\"\n",
PHP_CONFIG_FILE_PATH);
+				if (php_ini_scanned_path) {
+					zend_printf("Loaded Configuration File:         \"%s\"\n",
php_ini_scanned_path);
+				} else {
+					zend_printf("Loaded Configuration File:         (none)\n");
+				}
+				if (php_ini_opened_path) {
+					zend_printf("Scan for additional .ini files in: \"%s\"\n",
php_ini_opened_path);
+				} else {
+					zend_printf("Scan for additional .ini files in: (none)\n");
+				}
 				zend_printf("Additional .ini files parsed:      %s\n", php_ini_scanned_files ?
php_ini_scanned_files : "(none)");
 				break;
 			}


Thread (1 message)

  • Richard Schneeman via GitHub
« previous php.cvs (#134113) next »