From 2a6755da9b0532ff57ba31de498664b0e8533304 Mon Sep 17 00:00:00 2001 From: Akshat Saxena Date: Wed, 5 Aug 2026 10:57:38 +0530 Subject: [PATCH 1/4] Document handling of newlines in WP-CLI arguments Added information about handling arguments with newlines on Windows and PowerShell in WP-CLI commands. --- guides/common-issues.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/guides/common-issues.md b/guides/common-issues.md index cb6a1baf..de673601 100644 --- a/guides/common-issues.md +++ b/guides/common-issues.md @@ -190,6 +190,26 @@ Using UTF-8 in PHP arguments doesn't work on Windows for PHP <= 7.0, however it See also: [#4714](https://github.com/wp-cli/wp-cli/issues/4714) +### Arguments containing newlines are truncated on Windows + +On Windows, `wp` is a `.bat` wrapper around `php wp-cli.phar`. Batch files terminate a command at a newline, including a newline inside a quoted argument, because `cmd.exe` splits the line before quoting is evaluated. + +Any flags positioned after the multi-line value never reach WP-CLI. The command still succeeds with the arguments it did receive, so there is no error — WordPress silently applies its defaults for the missing values. In the example below the post is created, but as a draft under Uncategorized and authored by the default user, because `--post_category`, `--post_author` and `--post_status` were all dropped: + + wp post create --post_status=publish --post_content="" --post_category=3 --post_author=2 + +Pass the content over `STDIN` instead, using `-` as the positional argument. The newline then lives in the piped stream rather than in the command line, so nothing is truncated: + + cat content.html | wp post create - --post_status=publish --post_category=3 --post_author=2 + +The same applies in PowerShell: + + $content | wp post create - --post_status=publish --post_category=3 --post_author=2 + +`wp post create` and `wp post update` also accept a file path in place of `-`. + +See also: [#2712](https://github.com/wp-cli/wp-cli/issues/2712) + ### The installation hangs If the installation seems to hang forever while trying to clone the resources from GitHub, please ensure that you are allowed to connect to Github using SSL (port 443) and Git (port 9418) for outbound connections. From dab8688161f713683c46277138c840c6e86792fa Mon Sep 17 00:00:00 2001 From: Akshat Saxena Date: Wed, 5 Aug 2026 11:12:13 +0530 Subject: [PATCH 2/4] Use type instead of cat in the Windows example Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- guides/common-issues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/common-issues.md b/guides/common-issues.md index de673601..f90315a1 100644 --- a/guides/common-issues.md +++ b/guides/common-issues.md @@ -200,7 +200,7 @@ Any flags positioned after the multi-line value never reach WP-CLI. The command Pass the content over `STDIN` instead, using `-` as the positional argument. The newline then lives in the piped stream rather than in the command line, so nothing is truncated: - cat content.html | wp post create - --post_status=publish --post_category=3 --post_author=2 + type content.html | wp post create - --post_status=publish --post_category=3 --post_author=2 The same applies in PowerShell: From 7551c43f6eb41279d424250ecca8fed8af8236f0 Mon Sep 17 00:00:00 2001 From: Akshat Saxena Date: Wed, 5 Aug 2026 11:16:52 +0530 Subject: [PATCH 3/4] Reword default category and author wording Clarified the behavior of WP-CLI with multi-line arguments on Windows, specifying the default values applied when arguments are dropped. --- guides/common-issues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/common-issues.md b/guides/common-issues.md index f90315a1..4239914f 100644 --- a/guides/common-issues.md +++ b/guides/common-issues.md @@ -194,7 +194,7 @@ See also: [#4714](https://github.com/wp-cli/wp-cli/issues/4714) On Windows, `wp` is a `.bat` wrapper around `php wp-cli.phar`. Batch files terminate a command at a newline, including a newline inside a quoted argument, because `cmd.exe` splits the line before quoting is evaluated. -Any flags positioned after the multi-line value never reach WP-CLI. The command still succeeds with the arguments it did receive, so there is no error — WordPress silently applies its defaults for the missing values. In the example below the post is created, but as a draft under Uncategorized and authored by the default user, because `--post_category`, `--post_author` and `--post_status` were all dropped: +Any flags positioned after the multi-line value never reach WP-CLI. The command still succeeds with the arguments it did receive, so there is no error — WordPress silently applies its defaults for the missing values. In the example below the post is created, but as a draft under the site's default category and attributed to the current user, because `--post_category`, `--post_author` and `--post_status` were all dropped: wp post create --post_status=publish --post_content="" --post_category=3 --post_author=2 From 912f434971aa33737bc4dc4000f5814f0daa5d69 Mon Sep 17 00:00:00 2001 From: Akshat Saxena Date: Wed, 5 Aug 2026 17:25:31 +0530 Subject: [PATCH 4/4] Fix flag order in the Windows example to match the explanation Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- guides/common-issues.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/guides/common-issues.md b/guides/common-issues.md index 4239914f..71834ea2 100644 --- a/guides/common-issues.md +++ b/guides/common-issues.md @@ -194,10 +194,9 @@ See also: [#4714](https://github.com/wp-cli/wp-cli/issues/4714) On Windows, `wp` is a `.bat` wrapper around `php wp-cli.phar`. Batch files terminate a command at a newline, including a newline inside a quoted argument, because `cmd.exe` splits the line before quoting is evaluated. -Any flags positioned after the multi-line value never reach WP-CLI. The command still succeeds with the arguments it did receive, so there is no error — WordPress silently applies its defaults for the missing values. In the example below the post is created, but as a draft under the site's default category and attributed to the current user, because `--post_category`, `--post_author` and `--post_status` were all dropped: - - wp post create --post_status=publish --post_content="" --post_category=3 --post_author=2 +Any flags positioned after the multi-line value never reach WP-CLI. The command still succeeds with the arguments it did receive, so there is no error — WordPress silently applies its defaults for the missing values. In the example below the post is created, but as a draft under the site's default category and attributed to the current user, because everything after `--post_content` (`--post_category`, `--post_author` and `--post_status`) was dropped: + wp post create --post_content="" --post_category=3 --post_author=2 --post_status=publish Pass the content over `STDIN` instead, using `-` as the positional argument. The newline then lives in the piped stream rather than in the command line, so nothing is truncated: type content.html | wp post create - --post_status=publish --post_category=3 --post_author=2