Add a test for isTty when capturing
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1736043 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
index 7330f67..b787103 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
@@ -221,6 +221,7 @@
}
if (capturingOutput != null) {
streams[1] = capturingOutput;
+ toclose[1] = true;
}
List<Pipe> pipes = new ArrayList<>();
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
index 34e6400..ed8fbf3 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
@@ -455,6 +455,21 @@
assertEquals("'abc{}'", x.get(8).toString());
}
+ @Test
+ public void testIsTty() throws Exception
+ {
+ Context c = new Context();
+ c.addCommand("istty", this);
+ c.addCommand("echo", this);
+ assertEquals(true, c.execute("istty 1"));
+ assertEquals(false, c.execute("$(istty 1)"));
+ }
+
+ public boolean istty(CommandSession session, int fd)
+ {
+ return session.isTty(fd);
+ }
+
void each(CommandSession session, Collection<Object> list, Function closure)
throws Exception
{