Skip to content

Commit 2d0c422

Browse files
Fixes #4004: Do not set tty mode if stdout is redirected. (#4028)
1 parent 288ff63 commit 2d0c422

File tree

6 files changed

+50
-33
lines changed

6 files changed

+50
-33
lines changed

.scenarios.lock/php5/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"consolidation/output-formatters": "^3.3.1",
6565
"consolidation/robo": "^1.4.6",
6666
"consolidation/site-alias": "^3.0.0@stable",
67-
"consolidation/site-process": "^2.0.0@stable",
67+
"consolidation/site-process": "^2.0.1",
6868
"grasmash/yaml-expander": "^1.1.1",
6969
"league/container": "~2",
7070
"psr/log": "~1.0",

.scenarios.lock/php5/composer.lock

Lines changed: 13 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"consolidation/output-formatters": "^3.3.1",
4141
"consolidation/robo": "^1.4.6",
4242
"consolidation/site-alias": "^3.0.0@stable",
43-
"consolidation/site-process": "^2.0.0@stable",
43+
"consolidation/site-process": "^2.0.1",
4444
"grasmash/yaml-expander": "^1.1.1",
4545
"league/container": "~2",
4646
"psr/log": "~1.0",

composer.lock

Lines changed: 13 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Runtime/RedispatchHook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function redispatch(InputInterface $input)
100100
if (!TerminalUtils::isTty()) {
101101
$process->setInput(STDIN);
102102
} else {
103-
$process->setTty($this->getConfig()->get('ssh.tty', $input->isInteractive()));
103+
$process->setTty($this->getConfig()->get('ssh.tty', TerminalUtils::useTty() && $input->isInteractive()));
104104
}
105105
$process->mustRun($process->showRealtime());
106106

src/Utils/TerminalUtils.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
class TerminalUtils
66
{
77
/**
8-
* isTty determines if the STDIN stream is a TTY. If we cannot tell,
9-
* then we return a default value.
8+
* isTty determines if the STDIN stream is a TTY. We use this function
9+
* to determine whether or not we should redirect input of a process
10+
* using our STDIN stream. If we cannot tell, then we return a default value.
1011
*
1112
* @param bool $default Result to assume when the posix functions
1213
* are not available.
@@ -20,4 +21,22 @@ public static function isTty($default = true)
2021

2122
return posix_isatty(STDIN);
2223
}
24+
25+
/**
26+
* useTty determines if both the STDIN and STDOUT streams connect to a TTY.
27+
* We use this to determine whether we should use tty mode with our process
28+
* component. If we cannot tell, then we return a default value.
29+
*
30+
* @param bool $default Result to assume when the posix functions
31+
* are not available.
32+
* @return bool
33+
*/
34+
public static function useTty($default = true)
35+
{
36+
if (!function_exists('posix_isatty')) {
37+
return $default;
38+
}
39+
40+
return posix_isatty(STDOUT) && posix_isatty(STDIN);
41+
}
2342
}

0 commit comments

Comments
 (0)