Fix small evaluation problems in gogo

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@792069 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
index 116b1a8..8ec781e 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
@@ -224,11 +224,11 @@
                         if (sb == null)
                         {
                             sb = new StringBuilder();
-                            if (res != null)
-                            {
-                                sb.append(res);
-                                res = null;
-                            }
+                        }
+                        if (res != null)
+                        {
+                            sb.append(res);
+                            res = null;
                         }
                         if (start != p.current)
                         {
@@ -282,11 +282,11 @@
             if (sb == null)
             {
                 sb = new StringBuilder();
-                if (res != null)
-                {
-                    sb.append(res);
-                    res = null;
-                }
+            }
+            if (res != null)
+            {
+                sb.append(res);
+                res = null;
             }
             sb.append(new Parser(p.text.subSequence(start, p.current)).unescape());
         }
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
index 25dfc0d..8d47c14 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
@@ -47,7 +47,6 @@
         c.addCommand("echo", this);
         c.addCommand("capture", this);
         c.set("c", "a");
-        assertEquals("a  b", c.execute("echo \"$c  b\" | capture"));
 
         assertEquals("a b", c.execute("echo a b | capture"));
         assertEquals("a b", c.execute("echo 'a b' | capture"));
@@ -63,6 +62,7 @@
         assertEquals("a  b", c.execute("echo \"${c}  b\" | capture"));
         assertEquals("aa", c.execute("echo $c$c | capture"));
         assertEquals("a ;a", c.execute("echo a\\ \\;a | capture"));
+        assertEquals("baabab", c.execute("echo b${c}${c}b${c}b | capture"));
     }
 
     public void testScope() throws Exception