Author: gnodet
Date: Tue Aug 25 06:27:50 2009
New Revision: 807496

URL: http://svn.apache.org/viewvc?rev=807496&view=rev
Log:
FELIX-1520: <> evaluated the command too many times

Modified:
    
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
    
felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java

Modified: 
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java?rev=807496&r1=807495&r2=807496&view=diff
==============================================================================
--- 
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
 (original)
+++ 
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
 Tue Aug 25 06:27:50 2009
@@ -128,6 +128,11 @@
             System.err.println(buf);
         }
 
+        if (statement.size() == 1 && statement.get(0).charAt(0) == '<')
+        {
+            return eval(statement.get(0));
+        }
+
         Object result;
         List<Object> values = new ArrayList<Object>();
         for (CharSequence token : statement)

Modified: 
felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java?rev=807496&r1=807495&r2=807496&view=diff
==============================================================================
--- 
felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
 (original)
+++ 
felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
 Tue Aug 25 06:27:50 2009
@@ -35,6 +35,16 @@
 {
     int beentheredonethat = 0;
 
+    public void testEvaluatation() throws Exception {
+        Context c = new Context();
+        c.addCommand("echo", this);
+        c.addCommand("capture", this);
+
+        assertEquals("a", c.execute("echo a | capture"));
+        assertEquals("a", c.execute("<echo a> | capture"));
+        assertEquals("a", c.execute("<<echo a>> | capture"));
+    }
+
     public void testSpecialValues() throws Exception {
         Context c = new Context();
         assertEquals(false, c.execute("false"));


Reply via email to