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

Commit 3ed6b7a

Browse filesBrowse files
committed
merged branch Seldaek/mode-path (PR #5755)
This PR was merged into the 2.1 branch. Commits ------- cf1e02d [Console] Fix error when mode is not in PATH Discussion ---------- [Console] Fix error when mode is not in PATH Small bugfix, fixes composer/composer#1208
2 parents 13e6ce4 + cf1e02d commit 3ed6b7a
Copy full SHA for 3ed6b7a

File tree

Expand file treeCollapse file tree

1 file changed

+25
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-4
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+25-4Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,7 @@ protected function getTerminalWidth()
854854
return preg_replace('{^(\d+)x.*$}', '$1', $ansicon);
855855
}
856856

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

880-
exec('mode CON', $execData);
881-
if (preg_match('{lines:\s*(\d+)}i', $execData[3], $matches)) {
879+
if (preg_match('{lines:\s*(\d+)}i', $this->getConsoleMode(), $matches)) {
882880
return $matches[1];
883881
}
884882
}
@@ -966,6 +964,29 @@ private function getSttyColumns()
966964
}
967965
}
968966

967+
/**
968+
* Runs and parses mode CON if it's available, suppressing any error output
969+
*
970+
* @return string
971+
*/
972+
private function getConsoleMode()
973+
{
974+
if (!function_exists('proc_open')) {
975+
return;
976+
}
977+
978+
$descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
979+
$process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
980+
if (is_resource($process)) {
981+
$info = stream_get_contents($pipes[1]);
982+
fclose($pipes[1]);
983+
fclose($pipes[2]);
984+
proc_close($process);
985+
986+
return $info;
987+
}
988+
}
989+
969990
/**
970991
* Sorts commands in alphabetical order.
971992
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.