handbook/references/internal-api/wp-cli-utils-ispiped.md
Pascal Birchler 264cb131bf
Fix handbook information architecture
- Organize files in folders according to the desired structure
- Use directory iterator to loop through all files and folders (makes generation more robust)
2025-06-25 15:38:39 +02:00

2.5 KiB

WP_CLI\Utils\isPiped()

Checks whether the output of the current script is a TTY or a pipe / redirect


Usage

WP_CLI\Utils\isPiped()
@return (bool)

Notes

Returns true if STDOUT output is being redirected to a pipe or a file; false is output is being sent directly to the terminal.

If an env variable SHELL_PIPE exists, the returned result depends on its value. Strings like 1, 0, yes, no, that validate to booleans are accepted.

To enable ASCII formatting even when the shell is piped, use the ENV variable SHELL_PIPE=0.

SHELL_PIPE=0 wp plugin list | cat

Note that the db command forwards to the mysql client, which is unaware of the env variable. For db commands, pass the --table option instead.

wp db query --table "SELECT 1" | cat

Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.