]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Suppress stdin message if input is piped
authorJoshua Spence <josh@joshuaspence.com>
Fri, 2 Jan 2015 00:36:24 +0000 (11:36 +1100)
committerJoshua Spence <josh@joshuaspence.com>
Fri, 2 Jan 2015 00:36:24 +0000 (11:36 +1100)
Summary: Currently we output "Waiting for JSON parameters on stdin...", even if `stdin` is piped (for example, from `echo`).

Test Plan:
```lang=bash
> echo '{}' | arc call-conduit conduit.ping
{"error":null,"errorMessage":null,"response":"ip-10-161-81-110"}

> arc call-conduit conduit.ping
Waiting for JSON parameters on stdin...
{}
^D
{"error":null,"errorMessage":null,"response":"ip-10-161-81-110"}
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11122

src/workflow/ArcanistCallConduitWorkflow.php

index 9553d1d686b9a1e3ac6367e2881e91181878857d..2a5ea379c99928ad7086b5a386e7df45a2066580 100644 (file)
@@ -61,7 +61,11 @@ EOTEXT
     $method = reset($method);
 
     $console = PhutilConsole::getConsole();
-    $console->writeErr("%s\n", pht('Waiting for JSON parameters on stdin...'));
+    if (!function_exists('posix_isatty') || posix_isatty(STDIN)) {
+      $console->writeErr(
+        "%s\n",
+        pht('Waiting for JSON parameters on stdin...'));
+    }
     $params = @file_get_contents('php://stdin');
     $params = json_decode($params, true);
     if (!is_array($params)) {