make closure arguments start at $1 (rather than $0). FELIX-1494.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@892285 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 1b01fdd..c205775 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
@@ -464,7 +464,9 @@
if (name.length() == 1 && Character.isDigit(name.charAt(0)))
{
- return parms.get(name.charAt(0) - '0');
+ int i = name.charAt(0) - '0';
+ if (i > 0)
+ return parms.get(i - 1);
}
}
return session.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 804261c..bc521a1 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
@@ -151,8 +151,8 @@
assertEquals("3", c.execute("[a=2 b=3] get b"));
assertEquals("[3, 4]", c.execute("[1 2 [3 4] 5 6] get 2").toString());
assertEquals(5, c.execute("[1 2 [3 4] 5 6] size"));
- assertEquals("a", c.execute("e = { echo $0 } ; e a b"));
- assertEquals("b", c.execute("e = { echo $1 } ; e a b"));
+ assertEquals("a", c.execute("e = { echo $1 } ; e a b"));
+ assertEquals("b", c.execute("e = { echo $2 } ; e a b"));
assertEquals("b", c.execute("e = { $args } ; e echo b"));
assertEquals("ca b", c.execute("e = { echo c$args } ; e a b"));
assertEquals("c a b", c.execute("e = { echo c $args } ; e a b"));