Skip to content

Commit 23a8ee6

Browse files
committed
make history
1 parent 4a21ed1 commit 23a8ee6

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/WP_CLI/Shell/REPL.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,10 @@ private static function create_prompt_cmd( $prompt, $history_path ) {
198198
if ( $is_powershell ) {
199199
// PowerShell uses ` (backtick) for escaping but for strings single quotes are literal.
200200
// If prompt contains single quotes, we double them in PowerShell.
201-
$prompt_for_ps = str_replace( "'", "''", $prompt );
202-
$cmd = "\$line = Read-Host -Prompt '{$prompt_for_ps}'; Write-Output \$line;";
203-
return "powershell.exe -NoProfile -Command \"{$cmd}\"";
201+
$prompt_for_ps = str_replace( "'", "''", $prompt );
202+
$history_path_for_ps = str_replace( "'", "''", $history_path );
203+
$cmd = "\$line = Read-Host -Prompt '{$prompt_for_ps}'; if ( \$line ) { Add-Content -Path '{$history_path_for_ps}' -Value \$line; } Write-Output \$line;";
204+
return "powershell.exe -Command \"{$cmd}\"";
204205
}
205206

206207
if ( ! is_file( $shell_binary ) || ! is_readable( $shell_binary ) ) {

0 commit comments

Comments
 (0)