Author: dbaum
Date: Fri Dec 18 15:50:57 2009
New Revision: 892285
URL: http://svn.apache.org/viewvc?rev=892285&view=rev
Log:
make closure arguments start at $1 (rather than $0). FELIX-1494.
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=892285&r1=892284&r2=892285&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
Fri Dec 18 15:50:57 2009
@@ -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);
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=892285&r1=892284&r2=892285&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
Fri Dec 18 15:50:57 2009
@@ -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"));