Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0e94f1

Browse files
committed
bug #20328 [Console] Fix empty COLUMNS/LINES env vars (nicolas-grekas)
This PR was merged into the 3.2-dev branch. Discussion ---------- [Console] Fix empty COLUMNS/LINES env vars | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Here is a python app that fails otherwise: test.py: ```python import os int(os.environ.get('COLUMNS', 80)) ``` test.php: ```php <?php putenv('COLUMNS='); passthru('python test.py'); ``` result: ``` $ php test.php Traceback (most recent call last): File "test.py", line 3, in <module> int(os.environ.get('COLUMNS', 80)) ValueError: invalid literal for int() with base 10: '' ``` Commits ------- 8ad991e [Console] Fix empty COLUMNS/LINES env vars
2 parents 10d7ecc + 8ad991e commit b0e94f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Component/Console/Terminal.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function getWidth()
3131
self::initDimensions();
3232
}
3333

34-
return self::$width;
34+
return self::$width ?: 80;
3535
}
3636

3737
/**
@@ -49,7 +49,7 @@ public function getHeight()
4949
self::initDimensions();
5050
}
5151

52-
return self::$height;
52+
return self::$height ?: 50;
5353
}
5454

5555
private static function initDimensions()

0 commit comments

Comments
 (0)