Skip to content

Commit 1191ea5

Browse files
akshat009coderabbitai[bot]Copilotswissspidy
authored
Document Windows argument truncation when a value contains newlines (#659)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Pascal Birchler <pascalb@google.com>
1 parent f18f01a commit 1191ea5

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

guides/common-issues.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,25 @@ Using UTF-8 in PHP arguments doesn't work on Windows for PHP <= 7.0, however it
190190

191191
See also: [#4714](https://github.com/wp-cli/wp-cli/issues/4714)
192192

193+
### Arguments containing newlines are truncated on Windows
194+
195+
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.
196+
197+
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:
198+
199+
wp post create --post_content="<multi-line content>" --post_category=3 --post_author=2 --post_status=publish
200+
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:
201+
202+
type content.html | wp post create - --post_status=publish --post_category=3 --post_author=2
203+
204+
The same applies in PowerShell:
205+
206+
$content | wp post create - --post_status=publish --post_category=3 --post_author=2
207+
208+
`wp post create` and `wp post update` also accept a file path in place of `-`.
209+
210+
See also: [#2712](https://github.com/wp-cli/wp-cli/issues/2712)
211+
193212
### The installation hangs
194213
195214
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.

0 commit comments

Comments
 (0)