Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Console] Fix error when mode is not in PATH #5755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions 29 src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,7 @@ protected function getTerminalWidth()
return preg_replace('{^(\d+)x.*$}', '$1', $ansicon);
}

exec('mode CON', $execData);
if (preg_match('{columns:\s*(\d+)}i', $execData[4], $matches)) {
if (preg_match('{columns:\s*(\d+)}i', $this->getConsoleMode(), $matches)) {
return $matches[1];
}
}
Expand All @@ -877,8 +876,7 @@ protected function getTerminalHeight()
return preg_replace('{^\d+x\d+ \(\d+x(\d+)\)$}', '$1', trim($ansicon));
}

exec('mode CON', $execData);
if (preg_match('{lines:\s*(\d+)}i', $execData[3], $matches)) {
if (preg_match('{lines:\s*(\d+)}i', $this->getConsoleMode(), $matches)) {
return $matches[1];
}
}
Expand Down Expand Up @@ -966,6 +964,29 @@ private function getSttyColumns()
}
}

/**
* Runs and parses mode CON if it's available, suppressing any error output
*
* @return string
*/
private function getConsoleMode()
{
if (!function_exists('proc_open')) {
return;
}

$descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
$process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
if (is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);

return $info;
}
}

/**
* Sorts commands in alphabetical order.
*
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.