diff --git a/lib/cli/Shell.php b/lib/cli/Shell.php index 037fe77..b9ae380 100755 --- a/lib/cli/Shell.php +++ b/lib/cli/Shell.php @@ -112,8 +112,12 @@ static public function hide($hidden = true) { * * @return bool */ - static private function is_windows() { - return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; + static public function is_windows() { + $test_is_windows = getenv( 'WP_CLI_TEST_IS_WINDOWS' ); + if ( false !== $test_is_windows ) { + return (bool) $test_is_windows; + } + return strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN'; } } diff --git a/lib/cli/progress/Bar.php b/lib/cli/progress/Bar.php index 43f21b5..9c58f76 100644 --- a/lib/cli/progress/Bar.php +++ b/lib/cli/progress/Bar.php @@ -82,6 +82,10 @@ public function display($finish = false) { $timing = Streams::render($this->_formatTiming, compact('elapsed', 'estimated', 'current', 'total', 'percent')); $size = Shell::columns(); + // On Windows, the cursor wraps to the next line if the output fills the entire width. + if ( Shell::is_windows() ) { + $size -= 1; + } $size -= strlen($msg . $timing); if ( $size < 0 ) { $size = 0;