From efe5b19c04b6f6e284d7ce895c2348ba479f05a2 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Sun, 10 Aug 2014 12:52:56 -0700 Subject: [PATCH] Steal WP-CLI's `is_windows()` check for `Shell` --- lib/cli/Shell.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/cli/Shell.php b/lib/cli/Shell.php index 113d6e8..1334171 100755 --- a/lib/cli/Shell.php +++ b/lib/cli/Shell.php @@ -28,7 +28,7 @@ static public function columns() { static $columns; if ( null === $columns ) { - if (stripos(PHP_OS, 'indows') === false) { + if ( ! self::is_windows() ) { $columns = (int) exec('/usr/bin/env tput cols'); } @@ -71,6 +71,16 @@ static public function isPiped() { static public function hide($hidden = true) { system( 'stty ' . ( $hidden? '-echo' : 'echo' ) ); } + + /** + * Is this shell in Windows? + * + * @return bool + */ + static private function is_windows() { + return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; + } + } ?>