From 6565922d5bc3474a9bfdfcd74c6faa7f287e28b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Nov 2025 14:32:42 +0000 Subject: [PATCH 1/2] Initial plan From cf0435acca00efeaf92a8c06a4922ac6d164eb4d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Nov 2025 14:43:00 +0000 Subject: [PATCH 2/2] Fix history command to handle input starting with dash Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/shell.feature | 17 +++++++++++++++++ src/WP_CLI/Shell/REPL.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/features/shell.feature b/features/shell.feature index 301c61bc..d5595506 100644 --- a/features/shell.feature +++ b/features/shell.feature @@ -60,3 +60,20 @@ Feature: WordPress REPL bool(true) """ And STDERR should be empty + + Scenario: Input starting with dash + Given a WP install + And a session file: + """ + -1 + """ + + When I run `wp shell --basic < session` + Then STDOUT should contain: + """ + int(-1) + """ + And STDERR should not contain: + """ + history: -1: invalid option + """ diff --git a/src/WP_CLI/Shell/REPL.php b/src/WP_CLI/Shell/REPL.php index 15697bf0..99b8f1f8 100644 --- a/src/WP_CLI/Shell/REPL.php +++ b/src/WP_CLI/Shell/REPL.php @@ -137,7 +137,7 @@ private static function create_prompt_cmd( $prompt, $history_path ) { . 'LINE=""; ' . "read -re -p {$prompt} LINE; " . '[ $? -eq 0 ] || exit; ' - . 'history -s "$LINE"; ' + . 'history -s -- "$LINE"; ' . "history -w {$history_path}; " . 'echo $LINE; ';