@@ -31,7 +31,7 @@ static public function columns() {
3131 $ columns = null ;
3232 }
3333 if ( null === $ columns ) {
34- if ( function_exists ( 'exec ' ) ) {
34+ if ( ! ( $ columns = ( int ) getenv ( ' COLUMNS ' ) ) && function_exists ( 'exec ' ) ) {
3535 if ( self ::is_windows () ) {
3636 // Cater for shells such as Cygwin and Git bash where `mode CON` returns an incorrect value for columns.
3737 if ( ( $ shell = getenv ( 'SHELL ' ) ) && preg_match ( '/(?:bash|zsh)(?:\.exe)?$/ ' , $ shell ) && getenv ( 'TERM ' ) ) {
@@ -49,15 +49,13 @@ static public function columns() {
4949 }
5050 }
5151 } else {
52- if ( ! ( $ columns = (int ) getenv ( 'COLUMNS ' ) ) ) {
53- $ size = exec ( '/usr/bin/env stty size 2>/dev/null ' );
54- if ( '' !== $ size && preg_match ( '/[0-9]+ ([0-9]+)/ ' , $ size , $ matches ) ) {
55- $ columns = (int ) $ matches [1 ];
56- }
57- if ( ! $ columns ) {
58- if ( getenv ( 'TERM ' ) ) {
59- $ columns = (int ) exec ( '/usr/bin/env tput cols 2>/dev/null ' );
60- }
52+ $ size = exec ( '/usr/bin/env stty size 2>/dev/null ' );
53+ if ( '' !== $ size && preg_match ( '/[0-9]+ ([0-9]+)/ ' , $ size , $ matches ) ) {
54+ $ columns = (int ) $ matches [1 ];
55+ }
56+ if ( ! $ columns ) {
57+ if ( getenv ( 'TERM ' ) ) {
58+ $ columns = (int ) exec ( '/usr/bin/env tput cols 2>/dev/null ' );
6159 }
6260 }
6361 }
@@ -114,7 +112,7 @@ static public function hide($hidden = true) {
114112 */
115113 static public function is_windows () {
116114 $ test_is_windows = getenv ( 'WP_CLI_TEST_IS_WINDOWS ' );
117- if ( false !== $ test_is_windows ) {
115+ if ( false !== $ test_is_windows && '' !== $ test_is_windows ) {
118116 return (bool ) $ test_is_windows ;
119117 }
120118 return strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN ' ;
0 commit comments