FELIX-1325: gogo doesn't report a command not found error unless an argument is supplied

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@807497 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 b9625c6..78e26dc 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
@@ -184,6 +184,15 @@
                 {
                     return session.variables.remove(scmd);
                 }
+                else if (values.size() == 2)
+                {
+                    Object value = values.get(1);
+                    if (value instanceof CharSequence)
+                    {
+                        value = eval((CharSequence) value);
+                    }
+                    return assignment(scmd, value);
+                }
                 else
                 {
                     Object value = execute(values.get(1), values.subList(2, values.size()));
@@ -203,10 +212,6 @@
                     x = get(scopedFunction);
                     if (x == null || !(x instanceof Function))
                     {
-                        if (values.isEmpty())
-                        {
-                            return scmd;
-                        }
                         throw new IllegalArgumentException("Command not found:  " + scopedFunction);
                     }
                 }
@@ -438,10 +443,11 @@
 
     private Object var(CharSequence var) throws Exception
     {
-        Object v = eval(var);
-        if (v instanceof Closure) {
-            v = ((Closure) v).execute(session, null);
+        if (var.charAt(0) == '{')
+        {
+            var = var.subSequence(1, var.length() - 1);
         }
+        Object v = eval(var);
         String name = v.toString();
         return get(name);
     }
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 0ffdc98..54aeb02 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
@@ -35,7 +35,8 @@
 {
     int beentheredonethat = 0;
 
-    public void testEvaluatation() throws Exception {
+    public void testEvaluatation() throws Exception
+    {
         Context c = new Context();
         c.addCommand("echo", this);
         c.addCommand("capture", this);
@@ -45,14 +46,30 @@
         assertEquals("a", c.execute("<<echo a>> | capture"));
     }
 
-    public void testSpecialValues() throws Exception {
+    public void testUnknownCommand() throws Exception
+    {
+        Context c = new Context();
+        try
+        {
+            c.execute("echo");
+            fail("Execution should have failed due to missing command");
+        }
+        catch (IllegalArgumentException e)
+        {
+            // expected
+        }
+    }
+
+    public void testSpecialValues() throws Exception
+    {
         Context c = new Context();
         assertEquals(false, c.execute("false"));
         assertEquals(true, c.execute("true"));
         assertEquals(null, c.execute("null"));
     }
 
-    public void testQuotes() throws Exception {
+    public void testQuotes() throws Exception
+    {
         Context c = new Context();
         c.addCommand("echo", this);
         c.set("c", "a");