File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -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 }
You can’t perform that action at this time.
0 commit comments