8000 Allow terminal dimensions to be set to 0 (unbounded) · symfony/symfony@4c1b001 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c1b001

Browse files
committed
Allow terminal dimensions to be set to 0 (unbounded)
1 parent d41a3a5 commit 4c1b001

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/Symfony/Component/Console/Terminal.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ class Terminal
2323
*/
2424
public function getWidth()
2525
{
26-
if ($width = trim(getenv('COLUMNS'))) {
27-
return (int) $width;
26+
$width = getenv('COLUMNS');
27+
if (false !== $width) {
28+
return (int) trim($width);
2829
}
2930

3031
if (null === self::$width) {
@@ -41,8 +42,9 @@ public function getWidth()
4142
*/
4243
public function getHeight()
4344
{
44-
if ($height = trim(getenv('LINES'))) {
45-
return (int) $height;
45+
$height = getenv('LINES');
46+
if (false !== $height) {
47+
return (int) trim($height);
4648
}
4749

4850
if (null === self::$height) {

src/Symfony/Component/Console/Tests/TerminalTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,15 @@ public function test()
3030
$this->assertSame(120, $terminal->getWidth());
3131
$this->assertSame(60, $terminal->getHeight());
3232
}
33+
34+
public function test_zero_values()
35+
{
36+
putenv('COLUMNS=0');
37+
putenv('LINES=0');
38+
39+
$terminal = new Terminal();
40+
41+
$this->assertSame(0, $terminal->getWidth());
42+
$this->assertSame(0, $terminal->getHeight());
43+
}
3344
}

0 commit comments

Comments
 (0)
0