Skip to content

Commit e187756

Browse files
committed
Merge pull request #42 from dllh/master
Force an integer for the return of Shell::columns(). In cases such as a ...
2 parents 8abf2c1 + 7a0ad26 commit e187756

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/cli/Shell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Shell {
2525
*/
2626
static public function columns() {
2727
if (stripos(PHP_OS, 'indows') === false) {
28-
return exec('/usr/bin/env tput cols');
28+
return (int) exec('/usr/bin/env tput cols');
2929
}
3030
return 80; // default width of cmd window on Windows OS, maybe force using MODE CON COLS=XXX?
3131
}

lib/cli/progress/Bar.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public function display($finish = false) {
5656

5757
$size = Shell::columns();
5858
$size -= strlen($msg . $timing);
59+
if ( $size < 0 ) {
60+
$size = 0;
61+
}
5962

6063
$bar = str_repeat($this->_bars[0], floor($_percent * $size)) . $this->_bars[1];
6164
// substr is needed to trim off the bar cap at 100%

0 commit comments

Comments
 (0)