|
From: <cr...@us...> - 2009-06-07 14:13:11
|
Revision: 5550
http://jnode.svn.sourceforge.net/jnode/?rev=5550&view=rev
Author: crawley
Date: 2009-06-07 13:39:58 +0000 (Sun, 07 Jun 2009)
Log Message:
-----------
Style and javadoc fixes
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/CommandInfo.java
trunk/shell/src/shell/org/jnode/shell/CommandLine.java
trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java
trunk/shell/src/shell/org/jnode/shell/CommandRunner.java
trunk/shell/src/shell/org/jnode/shell/CommandShell.java
trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java
trunk/shell/src/shell/org/jnode/shell/ShellControlException.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SetFlagArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/PowersetSyntax.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTests.java
Modified: trunk/shell/src/shell/org/jnode/shell/CommandInfo.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2009-06-07 13:18:52 UTC (rev 5549)
+++ trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2009-06-07 13:39:58 UTC (rev 5550)
@@ -91,7 +91,8 @@
* @param syntaxBundle the syntax definition to parse the command line against
* @param instance a prebuilt command instance
*/
- CommandInfo(Class<?> clazz, String commandName, SyntaxBundle syntaxBundle, ArgumentBundle argBundle, Command instance) {
+ CommandInfo(Class<?> clazz, String commandName, SyntaxBundle syntaxBundle,
+ ArgumentBundle argBundle, Command instance) {
this.clazz = clazz;
this.internal = true;
this.commandName = commandName;
Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-06-07 13:18:52 UTC (rev 5549)
+++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-06-07 13:39:58 UTC (rev 5550)
@@ -22,7 +22,6 @@
import java.util.NoSuchElementException;
-import org.apache.log4j.Logger;
import org.jnode.driver.console.CompletionInfo;
import org.jnode.shell.help.CompletionException;
import org.jnode.shell.io.CommandIO;
Modified: trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java 2009-06-07 13:18:52 UTC (rev 5549)
+++ trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java 2009-06-07 13:39:58 UTC (rev 5550)
@@ -17,7 +17,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
- package org.jnode.shell;
+package org.jnode.shell;
public interface CommandRunnable extends Runnable {
Modified: trunk/shell/src/shell/org/jnode/shell/CommandRunner.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2009-06-07 13:18:52 UTC (rev 5549)
+++ trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2009-06-07 13:39:58 UTC (rev 5550)
@@ -86,22 +86,8 @@
try {
prepare();
execute();
-// } catch (CommandSyntaxException ex) {
-// try {
-// HelpFactory.getHelpFactory().getHelp(commandLine.getCommandName(), commandLine.getCommandInfo()).usage(shellErr);
-// shellErr.println(ex.getMessage());
-// } catch (HelpException e) {
-// shellErr.println("Exception while trying to get the command usage");
-// stackTrace(ex);
-// }
} catch (VmExit ex) {
setRC(ex.getStatus());
-// } catch (Exception ex) {
-// shellErr.println("Exception in command");
-// stackTrace(ex);
-// } catch (Throwable ex) {
-// shellErr.println("Fatal error in command");
-// stackTrace(ex);
} catch (Throwable ex) {
setTerminatingException(ex);
}
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-06-07 13:18:52 UTC (rev 5549)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-06-07 13:39:58 UTC (rev 5550)
@@ -908,7 +908,7 @@
/**
* Run a command script located using the shell's classloader. The behavior is analogous
- * to {@link #runCommandFile(File, String, String[]), with the resourceName used as the
+ * to {@link #runCommandFile(File, String, String[])}, with the resourceName used as the
* alias.
*
* @param resourceName the script resource name.
Modified: trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java 2009-06-07 13:18:52 UTC (rev 5549)
+++ trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java 2009-06-07 13:39:58 UTC (rev 5550)
@@ -33,7 +33,7 @@
private UncaughtExceptionHandler myUncaughtExceptionHandler = new UncaughtExceptionHandler() {
public void uncaughtException(Thread thr, Throwable exc) {
- synchronized(CommandThreadImpl.this) {
+ synchronized (CommandThreadImpl.this) {
terminatingException = exc;
}
}
Modified: trunk/shell/src/shell/org/jnode/shell/ShellControlException.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/ShellControlException.java 2009-06-07 13:18:52 UTC (rev 5549)
+++ trunk/shell/src/shell/org/jnode/shell/ShellControlException.java 2009-06-07 13:39:58 UTC (rev 5550)
@@ -17,7 +17,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
- package org.jnode.shell;
+package org.jnode.shell;
/**
* Subtypes of ShellControlException are used by interpreter and should be allowed
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/SetFlagArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/SetFlagArgument.java 2009-06-07 13:18:52 UTC (rev 5549)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/SetFlagArgument.java 2009-06-07 13:39:58 UTC (rev 5550)
@@ -17,7 +17,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
- package org.jnode.shell.bjorne;
+package org.jnode.shell.bjorne;
import org.jnode.driver.console.CompletionInfo;
import org.jnode.shell.CommandLine.Token;
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/PowersetSyntax.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/PowersetSyntax.java 2009-06-07 13:18:52 UTC (rev 5549)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/PowersetSyntax.java 2009-06-07 13:39:58 UTC (rev 5550)
@@ -73,7 +73,7 @@
res = new MuAlternation(label, null,
new MuSequence(new MuAlternation((String) null, childMuSyntaxes),
new MuBackReference(label)));
- }
+ }
res.resolveBackReferences();
return res;
}
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTests.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTests.java 2009-06-07 13:18:52 UTC (rev 5549)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTests.java 2009-06-07 13:39:58 UTC (rev 5550)
@@ -280,6 +280,7 @@
case 'Z':
// Expect completions if the last char is NOT ' '
if (wordStart >= partial.length()) {
+ //
} else {
assertTrue("got no completions: " + diag(partial, completions),
completionWords.size() > 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-06-08 07:34:53
|
Revision: 5560
http://jnode.svn.sourceforge.net/jnode/?rev=5560&view=rev
Author: crawley
Date: 2009-06-08 07:34:35 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
First argument of a command wasn't included in initial completions;
e.g. completing "dir " didn't include any pathnames in the completion set.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompleter.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTest.java
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompleter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompleter.java 2009-06-08 07:16:12 UTC (rev 5559)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompleter.java 2009-06-08 07:34:35 UTC (rev 5560)
@@ -63,6 +63,8 @@
if (words.length > 1 && words[words.length - 1] == penultimateToken) {
boolean argumentAnticipated = penultimateToken.end < endToken.end;
command.complete(completion, context, shell, argumentAnticipated);
+ } else if (words.length == 1 && words[0] == penultimateToken && penultimateToken.end < endToken.end) {
+ command.complete(completion, context, shell, true);
}
}
String partial;
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTest.java 2009-06-08 07:16:12 UTC (rev 5559)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTest.java 2009-06-08 07:34:35 UTC (rev 5560)
@@ -105,6 +105,10 @@
public void testPipe2Command() throws ShellSyntaxException, CompletionException {
doCompletionTest("echo hi |\necho", "TETT");
}
+
+ public void testSourceCommand() throws ShellSyntaxException, CompletionException {
+ doCompletionTest("source /", "TT");
+ }
public void testIfCommand() throws ShellSyntaxException, CompletionException {
doCompletionTest("if cpuid ; then echo hi ; fi", "TTTTTETT");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-06-09 14:05:17
|
Revision: 5566
http://jnode.svn.sourceforge.net/jnode/?rev=5566&view=rev
Author: crawley
Date: 2009-06-09 14:04:19 +0000 (Tue, 09 Jun 2009)
Log Message:
-----------
Compound commands now support redirection
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-06-09 12:33:55 UTC (rev 5565)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-06-09 14:04:19 UTC (rev 5566)
@@ -125,6 +125,8 @@
private String options = "";
private CommandIOHolder[] holders;
+
+ private List<CommandIOHolder[]> savedHolders;
private boolean echoExpansions;
@@ -1094,6 +1096,30 @@
}
/**
+ * Evaluate the redirections for this command, saving the context's existing IOs
+ *
+ * @param redirects the redirection nodes to be evaluated
+ * @throws ShellException
+ */
+ void evaluateRedirectionsAndPushHolders(RedirectionNode[] redirects) throws ShellException {
+ if (savedHolders == null) {
+ savedHolders = new ArrayList<CommandIOHolder[]>(1);
+ }
+ savedHolders.add(holders);
+ holders = copyStreamHolders(holders);
+ evaluateRedirections(redirects, holders);
+ }
+
+ /**
+ * Close the context's current IO, restoring the previous ones.
+ * @throws ShellException
+ */
+ void popHolders() {
+ closeIOs();
+ holders = savedHolders.remove(savedHolders.size() - 1);
+ }
+
+ /**
* Evaluate the redirections for this command.
*
* @param redirects the redirection nodes to be evaluated
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-06-09 12:33:55 UTC (rev 5565)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-06-09 14:04:19 UTC (rev 5566)
@@ -60,24 +60,28 @@
@Override
public int execute(BjorneContext context) throws ShellException {
- int rc = 0;
-
- CharSequence expandedWord = context.dollarBacktickExpand(word.text);
- LOOP:
- for (CaseItemNode caseItem : caseItems) {
- for (BjorneToken pattern : caseItem.getPattern()) {
- CharSequence pat = context.dollarBacktickExpand(pattern.text);
- if (context.patternMatch(expandedWord, pat)) {
- rc = caseItem.getBody().execute(context);
- break LOOP;
+ try {
+ int rc = 0;
+ context.evaluateRedirectionsAndPushHolders(getRedirects());
+ CharSequence expandedWord = context.dollarBacktickExpand(word.text);
+ LOOP:
+ for (CaseItemNode caseItem : caseItems) {
+ for (BjorneToken pattern : caseItem.getPattern()) {
+ CharSequence pat = context.dollarBacktickExpand(pattern.text);
+ if (context.patternMatch(expandedWord, pat)) {
+ rc = caseItem.getBody().execute(context);
+ break LOOP;
+ }
}
}
- }
- if ((getFlags() & BjorneInterpreter.FLAG_BANG) != 0) {
- rc = (rc == 0) ? -1 : 0;
+ if ((getFlags() & BjorneInterpreter.FLAG_BANG) != 0) {
+ rc = (rc == 0) ? -1 : 0;
+ }
+ return rc;
+ } finally {
+ context.popHolders();
}
- return rc;
}
@Override
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java 2009-06-09 12:33:55 UTC (rev 5565)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java 2009-06-09 14:04:19 UTC (rev 5566)
@@ -92,13 +92,18 @@
@Override
public int execute(BjorneContext context) throws ShellException {
- int rc = 0;
- List<BjorneToken> expanded = context.expandAndSplit(words);
- for (BjorneToken word : expanded) {
- context.setVariable(var.getText(), word.getText());
- rc = body.execute(context);
+ try {
+ int rc = 0;
+ context.evaluateRedirectionsAndPushHolders(getRedirects());
+ List<BjorneToken> expanded = context.expandAndSplit(words);
+ for (BjorneToken word : expanded) {
+ context.setVariable(var.getText(), word.getText());
+ rc = body.execute(context);
+ }
+ return rc;
+ } finally {
+ context.popHolders();
}
- return rc;
}
@Override
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java 2009-06-09 12:33:55 UTC (rev 5565)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java 2009-06-09 14:04:19 UTC (rev 5566)
@@ -100,20 +100,25 @@
@Override
public int execute(BjorneContext context) throws ShellException {
- int rc = cond.execute(context);
- if (rc == 0) {
- if (thenPart != null) {
- return thenPart.execute(context);
+ try {
+ context.evaluateRedirectionsAndPushHolders(getRedirects());
+ int rc = cond.execute(context);
+ if (rc == 0) {
+ if (thenPart != null) {
+ return thenPart.execute(context);
+ }
+ } else {
+ if (elsePart != null) {
+ return elsePart.execute(context);
+ }
}
- } else {
- if (elsePart != null) {
- return elsePart.execute(context);
+ if ((getFlags() & BjorneInterpreter.FLAG_BANG) != 0) {
+ rc = (rc == 0) ? -1 : 0;
}
+ return rc;
+ } finally {
+ context.popHolders();
}
- if ((getFlags() & BjorneInterpreter.FLAG_BANG) != 0) {
- rc = (rc == 0) ? -1 : 0;
- }
- return rc;
}
@Override
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java 2009-06-09 12:33:55 UTC (rev 5565)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java 2009-06-09 14:04:19 UTC (rev 5566)
@@ -30,7 +30,6 @@
import org.jnode.shell.Completable;
import org.jnode.shell.ShellException;
import org.jnode.shell.help.CompletionException;
-import org.jnode.shell.io.CommandIOHolder;
public class ListCommandNode extends CommandNode implements Completable {
@@ -59,25 +58,26 @@
public int execute(BjorneContext context) throws ShellException {
int listFlags = getFlags();
int rc = 0;
- try {
- if ((listFlags & BjorneInterpreter.FLAG_PIPE) != 0) {
- BjornePipeline pipeline = buildPipeline(context);
- try {
- pipeline.wire();
- rc = pipeline.run(context.getShell());
- } finally {
- pipeline.closeStreams();
- }
- } else {
- if (getNodeType() == BjorneInterpreter.CMD_SUBSHELL) {
+ if ((listFlags & BjorneInterpreter.FLAG_PIPE) != 0) {
+ BjornePipeline pipeline = buildPipeline(context);
+ try {
+ pipeline.wire();
+ rc = pipeline.run(context.getShell());
+ } finally {
+ pipeline.closeStreams();
+ }
+ } else {
+ int nt = getNodeType();
+ try {
+ if (nt == BjorneInterpreter.CMD_SUBSHELL) {
// This simulates creating a 'subshell'.
context = new BjorneContext(context);
- CommandIOHolder[] holders = context.evaluateRedirections(getRedirects());
- for (int i = 0; i < holders.length; i++) {
- context.setIO(i, holders[i]);
- }
+ context.evaluateRedirectionsAndPushHolders(getRedirects());
+ } else if (nt == BjorneInterpreter.CMD_BRACE_GROUP) {
+ context.evaluateRedirectionsAndPushHolders(getRedirects());
}
+
for (CommandNode command : commands) {
int commandFlags = command.getFlags();
if ((commandFlags & BjorneInterpreter.FLAG_AND_IF) != 0) {
@@ -92,11 +92,11 @@
}
rc = command.execute(context);
}
+ } finally {
+ if (nt == BjorneInterpreter.CMD_SUBSHELL || nt == BjorneInterpreter.CMD_BRACE_GROUP) {
+ context.popHolders();
+ }
}
- } finally {
- if (getNodeType() == BjorneInterpreter.CMD_SUBSHELL) {
- context.closeIOs();
- }
}
if ((listFlags & BjorneInterpreter.FLAG_BANG) != 0) {
rc = (rc == 0) ? -1 : 0;
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java 2009-06-09 12:33:55 UTC (rev 5565)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java 2009-06-09 14:04:19 UTC (rev 5566)
@@ -74,39 +74,44 @@
}
public int execute(BjorneContext context) throws ShellException {
- int rc = 0;
- while (true) {
- rc = cond.execute(context);
- if (rc != 0 && getNodeType() == BjorneInterpreter.CMD_WHILE ||
- rc == 0 && getNodeType() == BjorneInterpreter.CMD_UNTIL) {
- break;
- }
- try {
- if (body != null) {
- body.execute(context);
+ try {
+ int rc = 0;
+ context.evaluateRedirectionsAndPushHolders(getRedirects());
+ while (true) {
+ rc = cond.execute(context);
+ if (rc != 0 && getNodeType() == BjorneInterpreter.CMD_WHILE ||
+ rc == 0 && getNodeType() == BjorneInterpreter.CMD_UNTIL) {
+ break;
}
- } catch (BjorneControlException ex) {
- int control = ex.getControl();
- if (control == BjorneInterpreter.BRANCH_BREAK ||
- control == BjorneInterpreter.BRANCH_CONTINUE) {
- if (ex.getCount() > 1) {
- ex.decrementCount();
- throw ex;
+ try {
+ if (body != null) {
+ body.execute(context);
}
- if (control == BjorneInterpreter.BRANCH_BREAK) {
- break;
+ } catch (BjorneControlException ex) {
+ int control = ex.getControl();
+ if (control == BjorneInterpreter.BRANCH_BREAK ||
+ control == BjorneInterpreter.BRANCH_CONTINUE) {
+ if (ex.getCount() > 1) {
+ ex.decrementCount();
+ throw ex;
+ }
+ if (control == BjorneInterpreter.BRANCH_BREAK) {
+ break;
+ } else {
+ continue;
+ }
} else {
- continue;
+ throw ex;
}
- } else {
- throw ex;
}
}
+ if ((getFlags() & BjorneInterpreter.FLAG_BANG) != 0) {
+ rc = (rc == 0) ? -1 : 0;
+ }
+ return rc;
+ } finally {
+ context.popHolders();
}
- if ((getFlags() & BjorneInterpreter.FLAG_BANG) != 0) {
- rc = (rc == 0) ? -1 : 0;
- }
- return rc;
}
@Override
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-06-09 12:33:55 UTC (rev 5565)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-06-09 14:04:19 UTC (rev 5566)
@@ -859,4 +859,47 @@
false
</script>
</testSpec>
+ <testSpec title="brace group" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ { echo hi ; echo there ; }
+ </script>
+ <output>hi
+there
+</output>
+ </testSpec>
+ <testSpec title="brace group redir" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ { echo hi ; echo there ; } > @TEMP_DIR@/1
+ </script>
+ <file name="1" input="false">hi
+there
+</file>
+ </testSpec>
+ <testSpec title="for redir" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ for i in 1 2 3 ; do echo $i ; done > @TEMP_DIR@/1
+ </script>
+ <file name="1" input="false">1
+2
+3
+</file>
+ </testSpec>
+ <testSpec title="while redir" command="test" runMode="AS_SCRIPT" rc="1">
+ <script>#!bjorne
+ A=5
+ while expr $A != 0 ; do echo $A ; A=`expr $A - 1`; done > @TEMP_DIR@/1
+ </script>
+ <file name="1" input="false">1
+5
+1
+4
+1
+3
+1
+2
+1
+1
+0
+</file>
+ </testSpec>
</testSet>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-06-09 14:05:21
|
Revision: 5565
http://jnode.svn.sourceforge.net/jnode/?rev=5565&view=rev
Author: crawley
Date: 2009-06-09 12:33:55 +0000 (Tue, 09 Jun 2009)
Log Message:
-----------
Fix brace group parse bug, and "echo hi | aa=bb" bug.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjornePipeline.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-06-08 13:48:09 UTC (rev 5564)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-06-09 12:33:55 UTC (rev 5565)
@@ -501,7 +501,7 @@
private CommandNode parseBraceGroup() throws ShellSyntaxException {
next();
CommandNode compoundList = parseCompoundList(TOK_RBRACE_BIT);
- expectPeek(TOK_RBRACE_BIT);
+ expectNext(TOK_RBRACE_BIT, RULE_1_CONTEXT);
compoundList.setNodeType(CMD_BRACE_GROUP);
return compoundList;
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjornePipeline.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjornePipeline.java 2009-06-08 13:48:09 UTC (rev 5564)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjornePipeline.java 2009-06-09 12:33:55 UTC (rev 5565)
@@ -161,7 +161,11 @@
synchronized (this) {
for (PipelineStage stage : stages) {
ThreadCallback callback = new ThreadCallback(stage.context);
- stage.thread.start(callback);
+ if (stage.thread != null) {
+ stage.thread.start(callback);
+ } else {
+ callback.notifyThreadExited(null);
+ }
}
while (activeStageCount > 0) {
try {
@@ -171,7 +175,8 @@
break;
}
}
- return stages[stages.length - 1].thread.getReturnCode();
+ CommandThread lastThread = stages[stages.length - 1].thread;
+ return (lastThread == null) ? 0 : lastThread.getReturnCode();
}
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-06-08 13:48:09 UTC (rev 5564)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-06-09 12:33:55 UTC (rev 5565)
@@ -127,9 +127,13 @@
public CommandThread fork(CommandShell shell, BjorneContext context)
throws ShellException {
- CommandLine command = context.buildCommandLine(getWords());
- command.setStreams(context.getIOs());
- return shell.invokeAsynchronous(command);
+ if (words.length > 0) {
+ CommandLine command = context.buildCommandLine(words);
+ command.setStreams(context.getIOs());
+ return shell.invokeAsynchronous(command);
+ } else {
+ return null;
+ }
}
@Override
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-06-08 13:48:09 UTC (rev 5564)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-06-09 12:33:55 UTC (rev 5565)
@@ -775,6 +775,11 @@
<output>Hi
</output>
</testSpec>
+ <testSpec title="weird pipeline" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ echo Hi | aa=bb
+ </script>
+ </testSpec>
<testSpec title="subshell" command="test" runMode="AS_SCRIPT" rc="0">
<script>#!bjorne
echo > @TEMP_DIR@/1 Hi mum
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-06-11 13:41:55
|
Revision: 5567
http://jnode.svn.sourceforge.net/jnode/?rev=5567&view=rev
Author: crawley
Date: 2009-06-11 12:45:24 +0000 (Thu, 11 Jun 2009)
Log Message:
-----------
Bjorne now handles unknown command names w/o printing an exception and
exiting the current script. No we just get a one line error message on
the current stderr and rc set to 1.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/CommandInfo.java
trunk/shell/src/shell/org/jnode/shell/CommandShell.java
trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
Modified: trunk/shell/src/shell/org/jnode/shell/CommandInfo.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2009-06-09 14:04:19 UTC (rev 5566)
+++ trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2009-06-11 12:45:24 UTC (rev 5567)
@@ -218,9 +218,9 @@
bundle.parse(cmdLine, syntaxBundle);
}
} catch (InstantiationException ex) {
- throw new ShellException("Command class cannot be instantiated", ex);
+ throw new ShellInvocationException("Command class cannot be instantiated", ex);
} catch (IllegalAccessException ex) {
- throw new ShellException("Command class cannot be instantiated", ex);
+ throw new ShellInvocationException("Command class cannot be instantiated", ex);
}
}
}
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-06-09 14:04:19 UTC (rev 5566)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-06-11 12:45:24 UTC (rev 5567)
@@ -655,14 +655,14 @@
return new CommandInfo(cls, cmd, syntaxBundle, argBundle);
}
} catch (ClassNotFoundException ex) {
- throw new ShellException("Cannot load the command class for alias '" + cmd + "'", ex);
+ throw new ShellInvocationException("Cannot load the command class for alias '" + cmd + "'", ex);
} catch (NoSuchAliasException ex) {
try {
final ClassLoader cl =
Thread.currentThread().getContextClassLoader();
return new CommandInfo(cl.loadClass(cmd), cmd, syntaxBundle, false);
} catch (ClassNotFoundException ex2) {
- throw new ShellException(
+ throw new ShellInvocationException(
"Cannot find an alias or load a command class for '" + cmd + "'", ex);
}
}
@@ -900,7 +900,7 @@
}
return interpreter.interpret(this, file, alias, args);
} catch (IOException ex) {
- throw new ShellException("Cannot open command file: " + ex.getMessage(), ex);
+ throw new ShellInvocationException("Cannot open command file: " + ex.getMessage(), ex);
} finally {
setHistoryEnabled(enabled);
}
@@ -918,7 +918,7 @@
try {
InputStream input = getClass().getResourceAsStream(resourceName);
if (input == null) {
- throw new ShellException("Cannot find resource '" + resourceName + "'");
+ throw new ShellInvocationException("Cannot find resource '" + resourceName + "'");
}
CommandInterpreter interpreter = createInterpreter(new InputStreamReader(input));
Reader reader = new InputStreamReader(getClass().getResourceAsStream(resourceName));
Modified: trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-06-09 14:04:19 UTC (rev 5566)
+++ trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-06-11 12:45:24 UTC (rev 5567)
@@ -114,7 +114,7 @@
public int interpret(CommandShell shell, Reader reader, String alias, String[] args)
throws ShellException {
if (args != null && args.length > 0) {
- throw new ShellException(
+ throw new ShellInvocationException(
"The " + getName() + " interpreter does not support script file arguments");
}
try {
@@ -130,7 +130,7 @@
}
return rc;
} catch (IOException ex) {
- throw new ShellException("Problem reading command file: " + ex.getMessage(), ex);
+ throw new ShellInvocationException("Problem reading command file: " + ex.getMessage(), ex);
} finally {
if (reader != null) {
try {
@@ -161,7 +161,7 @@
try {
return interpret(shell, new FileReader(file), alias, args);
} catch (FileNotFoundException ex) {
- throw new ShellException("Problem reading command file: " + ex.getMessage(), ex);
+ throw new ShellInvocationException("Problem reading command file: " + ex.getMessage(), ex);
}
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-06-09 14:04:19 UTC (rev 5566)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-06-11 12:45:24 UTC (rev 5567)
@@ -24,6 +24,7 @@
import org.jnode.shell.Command;
import org.jnode.shell.CommandLine;
import org.jnode.shell.ShellException;
+import org.jnode.shell.ShellInvocationException;
import org.jnode.vm.VmExit;
/**
@@ -64,7 +65,7 @@
} catch (VmExit ex) {
return ex.getStatus();
} catch (Exception ex) {
- throw new ShellException("Exception in bjorne builtin", ex);
+ throw new ShellInvocationException("Exception in bjorne builtin", ex);
}
return 0;
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-06-09 14:04:19 UTC (rev 5566)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-06-11 12:45:24 UTC (rev 5567)
@@ -51,6 +51,7 @@
import org.jnode.shell.IncompleteCommandException;
import org.jnode.shell.ShellException;
import org.jnode.shell.ShellFailureException;
+import org.jnode.shell.ShellInvocationException;
import org.jnode.shell.ShellSyntaxException;
import org.jnode.shell.io.CommandIO;
import org.jnode.shell.io.CommandOutput;
@@ -288,7 +289,7 @@
}
return rc;
} catch (IOException ex) {
- throw new ShellException("Problem reading command file: " + ex.getMessage(), ex);
+ throw new ShellInvocationException("Problem reading command file: " + ex.getMessage(), ex);
} finally {
if (reader != null) {
try {
@@ -305,7 +306,7 @@
try {
return interpret(shell, new FileReader(file), alias, args);
} catch (FileNotFoundException ex) {
- throw new ShellException("Problem reading command file: " + ex.getMessage(), ex);
+ throw new ShellInvocationException("Problem reading command file: " + ex.getMessage(), ex);
}
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-06-09 14:04:19 UTC (rev 5566)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-06-11 12:45:24 UTC (rev 5567)
@@ -26,6 +26,7 @@
import org.jnode.shell.CommandThread;
import org.jnode.shell.ShellException;
import org.jnode.shell.ShellFailureException;
+import org.jnode.shell.ShellInvocationException;
import org.jnode.shell.help.CompletionException;
import org.jnode.shell.io.CommandIO;
import org.jnode.shell.io.CommandIOHolder;
@@ -111,6 +112,9 @@
rc = childContext.execute(command, ios, builtin);
}
}
+ } catch (ShellInvocationException ex) {
+ context.getShell().resolvePrintStream(context.getIO(2)).println(ex.getMessage());
+ rc = 1;
} finally {
if (holders != null) {
for (CommandIOHolder holder : holders) {
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml 2009-06-09 14:04:19 UTC (rev 5566)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml 2009-06-11 12:45:24 UTC (rev 5567)
@@ -74,8 +74,7 @@
<output>fred='ls'
</output>
</testSpec>
- <testSpec title="builtins recognized early" command="test"
- runMode="AS_SCRIPT" rc="0" trapException="org.jnode.shell.ShellException">
+ <testSpec title="builtins recognized early" command="test" runMode="AS_SCRIPT" rc="0">
<script>#!bjorne
alias fred=ls
alias
@@ -90,6 +89,9 @@
<output>fred='ls'
done
fred='dir'
+done
</output>
+ <error>Cannot find an alias or load a command class for 'unalias'
+</error>
</testSpec>
</testSet>
\ No newline at end of file
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-06-09 14:04:19 UTC (rev 5566)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-06-11 12:45:24 UTC (rev 5567)
@@ -902,4 +902,14 @@
0
</file>
</testSpec>
+ <testSpec title="unknown command" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ foo
+ echo hi
+ </script>
+ <output >hi
+</output>
+ <error>Cannot find an alias or load a command class for 'foo'
+</error>
+ </testSpec>
</testSet>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-06-13 05:09:45
|
Revision: 5570
http://jnode.svn.sourceforge.net/jnode/?rev=5570&view=rev
Author: crawley
Date: 2009-06-13 05:09:38 +0000 (Sat, 13 Jun 2009)
Log Message:
-----------
Implemented the 'readonly' builtin command
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ExportBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml
Added Paths:
-----------
trunk/shell/src/shell/org/jnode/shell/bjorne/ReadonlyBuiltin.java
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-06-12 16:56:18 UTC (rev 5569)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-06-13 05:09:38 UTC (rev 5570)
@@ -264,13 +264,13 @@
* @param name the name of the variable to be set
* @param value a non-null value for the variable
*/
- public void setVariable(String name, String value) {
+ protected void setVariable(String name, String value) {
value.length(); // Check that the value is non-null.
VariableSlot var = variables.get(name);
if (var == null) {
variables.put(name, new VariableSlot(name, value, false));
- } else {
- var.value = value;
+ } else if (!var.isReadOnly()) {
+ var.setValue(value);
}
}
@@ -289,23 +289,39 @@
*
* @param name the name of the variable to be unset
*/
- void unsetVariableValue(String name) {
- variables.remove(name);
+ void unsetVariable(String name) {
+ if (!variables.get(name).isReadOnly()) {
+ variables.remove(name);
+ }
}
/**
+ * This method implements 'readonly NAME'
+ *
+ * @param name the name of the variable to be marked as readonly
+ */
+ void setVariableReadonly(String name, boolean readonly) {
+ VariableSlot var = variables.get(name);
+ if (var == null) {
+ var = new VariableSlot(name, "", false);
+ variables.put(name, var);
+ }
+ var.setReadOnly(readonly);
+ }
+
+ /**
* This method implements 'export NAME' or 'unexport NAME'.
*
* @param name the name of the variable to be exported / unexported
*/
- void setExported(String name, boolean exported) {
+ void setVariableExported(String name, boolean exported) {
VariableSlot var = variables.get(name);
if (var == null) {
if (exported) {
variables.put(name, new VariableSlot(name, "", exported));
}
} else {
- var.exported = exported;
+ var.setExported(exported);
}
}
@@ -921,7 +937,7 @@
private String variable(String parameter) throws ShellSyntaxException {
if (BjorneToken.isName(parameter)) {
VariableSlot var = variables.get(parameter);
- return (var != null) ? var.value : null;
+ return (var != null) ? var.getValue() : null;
} else {
try {
int argNo = Integer.parseInt(parameter);
@@ -1003,8 +1019,8 @@
private Map<String, String> buildEnvFromExports() {
HashMap<String, String> map = new HashMap<String, String>(variables.size());
for (VariableSlot var : variables.values()) {
- if (var.exported) {
- map.put(var.name, var.value);
+ if (var.isExported()) {
+ map.put(var.getName(), var.getValue());
}
}
return Collections.unmodifiableMap(map);
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-06-12 16:56:18 UTC (rev 5569)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-06-13 05:09:38 UTC (rev 5570)
@@ -143,6 +143,7 @@
BUILTINS.put("continue", ContinueBuiltin.FACTORY);
BUILTINS.put("exit", ExitBuiltin.FACTORY);
BUILTINS.put("export", ExportBuiltin.FACTORY);
+ BUILTINS.put("readonly", ReadonlyBuiltin.FACTORY);
BUILTINS.put("return", ReturnBuiltin.FACTORY);
BUILTINS.put("set", SetBuiltin.FACTORY);
BUILTINS.put("shift", ShiftBuiltin.FACTORY);
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ExportBuiltin.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/ExportBuiltin.java 2009-06-12 16:56:18 UTC (rev 5569)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/ExportBuiltin.java 2009-06-13 05:09:38 UTC (rev 5570)
@@ -42,39 +42,39 @@
}
};
- private final AssignmentArgument argExport;
+ private final AssignmentArgument argVariables;
ExportBuiltin(BjorneContext context) {
super("Export shell variables to the environment");
- argExport = new AssignmentArgument(
+ argVariables = new AssignmentArgument(
"export", context, Argument.MANDATORY, "variables to be exported");
- registerArguments(argExport);
+ registerArguments(argVariables);
}
public void execute() throws Exception {
int errorCount = 0;
- if (!argExport.isSet()) {
+ if (!argVariables.isSet()) {
// FIXME - implement this?
} else {
BjorneContext pc = getParentContext();
PrintWriter err = getError().getPrintWriter();
- for (String arg : argExport.getValues()) {
- int pos = arg.indexOf('=');
+ for (String var : argVariables.getValues()) {
+ int pos = var.indexOf('=');
if (pos == -1) {
- pc.setExported(arg, true);
+ pc.setVariableExported(var, true);
} else if (pos == 0) {
- err.println("export: " + arg + ": not a valid identifier");
+ err.println("export: " + var + ": not a valid identifier");
errorCount++;
} else {
- String name = arg.substring(0, pos);
- String value = arg.substring(pos + 1);
+ String name = var.substring(0, pos);
+ String value = var.substring(pos + 1);
if (!BjorneToken.isName(name)) {
err.println("export: " + name + ": not a valid identifier");
errorCount++;
}
pc.setVariable(name, value);
- pc.setExported(name, true);
+ pc.setVariableExported(name, true);
}
}
}
Added: trunk/shell/src/shell/org/jnode/shell/bjorne/ReadonlyBuiltin.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/ReadonlyBuiltin.java (rev 0)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/ReadonlyBuiltin.java 2009-06-13 05:09:38 UTC (rev 5570)
@@ -0,0 +1,85 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2003-2009 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.jnode.shell.bjorne;
+
+import java.io.PrintWriter;
+
+import org.jnode.shell.syntax.Argument;
+import org.jnode.shell.syntax.ArgumentSyntax;
+import org.jnode.shell.syntax.RepeatSyntax;
+import org.jnode.shell.syntax.SyntaxBundle;
+
+/**
+ * This class implements the 'readonly' built-in.
+ *
+ * @author cr...@jn...
+ */
+final class ReadonlyBuiltin extends BjorneBuiltin {
+ private static final SyntaxBundle SYNTAX =
+ new SyntaxBundle("readonly", new RepeatSyntax(new ArgumentSyntax("readonly")));
+
+ static final Factory FACTORY = new Factory() {
+ public BjorneBuiltinCommandInfo buildCommandInfo(BjorneContext context) {
+ return new BjorneBuiltinCommandInfo("readonly", SYNTAX, new ReadonlyBuiltin(context), context);
+ }
+ };
+
+ private final AssignmentArgument argVariables;
+
+
+ ReadonlyBuiltin(BjorneContext context) {
+ super("Mark shell variables as readonly");
+ argVariables = new AssignmentArgument(
+ "readonly", context, Argument.MANDATORY, "variables to be marked as readonly");
+ registerArguments(argVariables);
+ }
+
+ public void execute() throws Exception {
+ int errorCount = 0;
+ if (!argVariables.isSet()) {
+ // FIXME - implement this?
+ } else {
+ BjorneContext pc = getParentContext();
+ PrintWriter err = getError().getPrintWriter();
+ for (String var : argVariables.getValues()) {
+ int pos = var.indexOf('=');
+ if (pos == -1) {
+ pc.setVariableReadonly(var, true);
+ } else if (pos == 0) {
+ err.println("readonly: " + var + ": not a valid identifier");
+ errorCount++;
+ } else {
+ String name = var.substring(0, pos);
+ String value = var.substring(pos + 1);
+ if (!BjorneToken.isName(name)) {
+ err.println("readonly: " + name + ": not a valid identifier");
+ errorCount++;
+ }
+ pc.setVariable(name, value);
+ pc.setVariableReadonly(name, true);
+ }
+ }
+ }
+ if (errorCount > 0) {
+ exit(1);
+ }
+ }
+}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java 2009-06-12 16:56:18 UTC (rev 5569)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java 2009-06-13 05:09:38 UTC (rev 5570)
@@ -22,11 +22,12 @@
import org.jnode.shell.ShellFailureException;
class VariableSlot {
- public String value;
- public final String name;
- public boolean exported;
+ private String value;
+ private final String name;
+ private boolean exported;
+ private boolean readOnly;
- public VariableSlot(String name, String value, boolean exported) {
+ VariableSlot(String name, String value, boolean exported) {
if (name == null) {
throw new ShellFailureException("null name");
}
@@ -38,9 +39,38 @@
this.name = name;
}
- public VariableSlot(VariableSlot other) {
+ VariableSlot(VariableSlot other) {
this.value = other.value;
this.exported = other.exported;
this.name = other.name;
}
+
+ String getValue() {
+ return value;
+ }
+
+ void setValue(String value) {
+ this.value = value;
+ }
+
+ boolean isExported() {
+ return exported;
+ }
+
+ void setExported(boolean exported) {
+ this.exported = exported;
+ }
+
+ boolean isReadOnly() {
+ return readOnly;
+ }
+
+ void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ String getName() {
+ return name;
+ }
+
}
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java 2009-06-12 16:56:18 UTC (rev 5569)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java 2009-06-13 05:09:38 UTC (rev 5570)
@@ -31,10 +31,29 @@
import org.jnode.shell.PathnamePattern;
import org.jnode.shell.ShellException;
import org.jnode.shell.bjorne.BjorneContext;
+import org.jnode.shell.bjorne.BjorneInterpreter;
import org.jnode.shell.bjorne.BjorneToken;
import org.jnode.shell.io.CommandIOHolder;
+/**
+ * Some unit tests for the BjorneContext class, focusing on the expansion and word-splitting
+ * methods.
+ *
+ * @author cr...@jn...
+ */
public class BjorneContextTest extends TestCase {
+
+ // This class simply allows us to call the setVariable method directly
+ private static class TestBjorneContext extends BjorneContext {
+ TestBjorneContext(BjorneInterpreter interpreter, CommandIOHolder[] holders) {
+ super(interpreter, holders);
+ }
+
+ @Override
+ protected void setVariable(String name, String value) {
+ super.setVariable(name, value);
+ }
+ }
public void testContext() {
new BjorneContext(null, null);
@@ -96,7 +115,7 @@
}
public void testExpand10() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext(null, null);
context.setVariable("A", "A");
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("$A"));
@@ -104,7 +123,7 @@
}
public void testExpand11() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext(null, null);
context.setVariable("A", "A");
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("\\$A"));
@@ -112,7 +131,7 @@
}
public void testExpand12() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext(null, null);
context.setVariable("A", "A");
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("\"$A\""));
@@ -120,7 +139,7 @@
}
public void testExpand13() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext(null, null);
context.setVariable("A", "A");
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("'$A'"));
@@ -128,7 +147,7 @@
}
public void testExpand14() throws ShellException {
- BjorneContext parentContext = new BjorneContext(null, new CommandIOHolder[0]);
+ TestBjorneContext parentContext = new TestBjorneContext(null, new CommandIOHolder[0]);
parentContext.setVariable("A", "A");
BjorneContext context = new BjorneContext(parentContext);
List<BjorneToken> expansion = context.expandAndSplit(
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml 2009-06-12 16:56:18 UTC (rev 5569)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml 2009-06-13 05:09:38 UTC (rev 5570)
@@ -94,4 +94,28 @@
<error>Cannot find an alias or load a command class for 'unalias'
</error>
</testSpec>
+ <testSpec title="readonly" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ readonly A
+ echo A -${A}-
+ A=1
+ echo A -${A}-
+ readonly B=1
+ echo B -${B}-
+ B=2
+ echo B -${B}-
+ readonly B=2
+ echo B -${B}-
+ export B=2
+ echo B -${B}-
+ </script>
+ <output>A --
+A --
+B -1-
+B -1-
+B -1-
+B -1-
+B -1-
+</output>
+ </testSpec>
</testSet>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-06-13 11:49:18
|
Revision: 5571
http://jnode.svn.sourceforge.net/jnode/?rev=5571&view=rev
Author: crawley
Date: 2009-06-13 11:49:13 +0000 (Sat, 13 Jun 2009)
Log Message:
-----------
Implement 'unset' builtin
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml
Added Paths:
-----------
trunk/shell/src/shell/org/jnode/shell/bjorne/UnsetBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/VariableNameArgument.java
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-06-13 05:09:38 UTC (rev 5570)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-06-13 11:49:13 UTC (rev 5571)
@@ -275,7 +275,7 @@
}
/**
- * Test if the variable is currently set here in this context.
+ * Test if the variable is set in this context.
*
* @param name the name of the variable to be tested
* @return <code>true</code> if the variable is set.
@@ -285,6 +285,17 @@
}
/**
+ * Test if the variable is readonly in this context.
+ *
+ * @param name the name of the variable to be tested
+ * @return <code>true</code> if the variable is set.
+ */
+ boolean isVariableReadonly(String name) {
+ VariableSlot var = variables.get(name);
+ return var != null && var.isReadOnly();
+ }
+
+ /**
* This method implements 'unset NAME'
*
* @param name the name of the variable to be unset
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-06-13 05:09:38 UTC (rev 5570)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-06-13 11:49:13 UTC (rev 5571)
@@ -149,6 +149,7 @@
BUILTINS.put("shift", ShiftBuiltin.FACTORY);
BUILTINS.put("source", SourceBuiltin.FACTORY);
BUILTINS.put("unalias", UnaliasBuiltin.FACTORY);
+ BUILTINS.put("unset", UnsetBuiltin.FACTORY);
BUILTINS.put(".", SourceBuiltin.FACTORY);
BUILTINS.put(":", ColonBuiltin.FACTORY);
}
Added: trunk/shell/src/shell/org/jnode/shell/bjorne/UnsetBuiltin.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/UnsetBuiltin.java (rev 0)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/UnsetBuiltin.java 2009-06-13 11:49:13 UTC (rev 5571)
@@ -0,0 +1,71 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2003-2009 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.jnode.shell.bjorne;
+
+import org.jnode.shell.syntax.Argument;
+import org.jnode.shell.syntax.ArgumentSyntax;
+import org.jnode.shell.syntax.RepeatSyntax;
+import org.jnode.shell.syntax.SyntaxBundle;
+
+/**
+ * This class implements the 'unset' built-in.
+ *
+ * @author cr...@jn...
+ */
+final class UnsetBuiltin extends BjorneBuiltin {
+ private static final SyntaxBundle SYNTAX =
+ new SyntaxBundle("unset", new RepeatSyntax(new ArgumentSyntax("unset")));
+
+ static final Factory FACTORY = new Factory() {
+ public BjorneBuiltinCommandInfo buildCommandInfo(BjorneContext context) {
+ return new BjorneBuiltinCommandInfo("unset", SYNTAX, new UnsetBuiltin(context), context);
+ }
+ };
+
+ private final VariableNameArgument argVariables;
+
+
+ UnsetBuiltin(BjorneContext context) {
+ super("Export shell variables to the environment");
+ argVariables = new VariableNameArgument(
+ "unset", context, Argument.MANDATORY, "variables to be unset");
+ registerArguments(argVariables);
+ }
+
+ public void execute() throws Exception {
+ int errorCount = 0;
+ if (!argVariables.isSet()) {
+ // FIXME - implement this?
+ } else {
+ BjorneContext pc = getParentContext();
+ for (String var : argVariables.getValues()) {
+ if (pc.isVariableReadonly(var)) {
+ errorCount++;
+ } else {
+ pc.unsetVariable(var);
+ }
+ }
+ }
+ if (errorCount > 0) {
+ exit(1);
+ }
+ }
+}
Added: trunk/shell/src/shell/org/jnode/shell/bjorne/VariableNameArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/VariableNameArgument.java (rev 0)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/VariableNameArgument.java 2009-06-13 11:49:13 UTC (rev 5571)
@@ -0,0 +1,65 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2003-2009 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+package org.jnode.shell.bjorne;
+
+import org.jnode.driver.console.CompletionInfo;
+import org.jnode.shell.CommandLine.Token;
+import org.jnode.shell.syntax.Argument;
+import org.jnode.shell.syntax.CommandSyntaxException;
+
+/**
+ * The VariableNameArgument understands 'arguments' of the form <name> where
+ * the name is a Bjorne shell variable name.
+ * It will perform completion of the <name> component against the variable names
+ * defined in a supplied BjorneContext.
+ *
+ * @author cr...@jn...
+ */
+public class VariableNameArgument extends Argument<String> {
+ private final BjorneContext context;
+
+ public VariableNameArgument(String label, BjorneContext context, int flags, String description) {
+ super(label, flags, new String[0], description);
+ this.context = context;
+ }
+
+ @Override
+ protected String argumentKind() {
+ return "bjorne variable name";
+ }
+
+ @Override
+ protected String doAccept(Token value, int flags) throws CommandSyntaxException {
+ String name = value.text;
+ if (!BjorneToken.isName(name)) {
+ throw new CommandSyntaxException("invalid name ('" + name + "')");
+ }
+ return name;
+ }
+
+ @Override
+ public void doComplete(CompletionInfo completions, String partial, int flags) {
+ for (String varName : context.getVariableNames()) {
+ if (varName.startsWith(partial)) {
+ completions.addCompletion(varName, true);
+ }
+ }
+ }
+}
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml 2009-06-13 05:09:38 UTC (rev 5570)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml 2009-06-13 11:49:13 UTC (rev 5571)
@@ -115,7 +115,17 @@
B -1-
B -1-
B -1-
-B -1-
</output>
</testSpec>
+ <testSpec title="unset" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ A=1
+ echo A -${A}-
+ unset A
+ echo A -${A}-
+ </script>
+ <output>A -1-
+A --
+</output>
+ </testSpec>
</testSet>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-07-06 14:33:05
|
Revision: 5593
http://jnode.svn.sourceforge.net/jnode/?rev=5593&view=rev
Author: crawley
Date: 2009-07-06 14:33:04 +0000 (Mon, 06 Jul 2009)
Log Message:
-----------
Change the shell / interpreter interactions to handle multi-line input
more cleanly. This will allow some bjorne features to be implemented.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java
trunk/shell/src/shell/org/jnode/shell/CommandShell.java
trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java
trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SetBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SourceBuiltin.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTest.java
Modified: trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-07-05 06:40:00 UTC (rev 5592)
+++ trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-07-06 14:33:04 UTC (rev 5593)
@@ -41,24 +41,14 @@
}
/**
- * Parse and execute a command line, and return the resulting return code.
+ * Parse and execute commands read from a reader, returning the resulting return code.
*
* @param shell the CommandShell that provides low-level command invocation,
* command history and so on.
- * @param line the line of input to be interpreted.
- * @return the return code.
- * @throws ShellException
- */
- int interpret(CommandShell shell, String line) throws ShellException;
-
- /**
- * Parse and execute a command file, returning the resulting return code.
- *
- * @param shell the CommandShell that provides low-level command invocation,
- * command history and so on.
* @param reader the reader to be interpreted. <b>The implementation must close it.</b>
- * @param alias this will supply the script's notional command name to the interpreter.
- * @param args command line arguments to be passed to the script. If this parameter
+ * @param alias this will supply a script's notional command name to the interpreter. If
+ * this parameter is {@code null}, no command name passed.
+ * @param args optional command line arguments to be passed to the script. If this parameter
* is {@code null}, no arguments are passed.
* @return the return code.
* @throws ShellException
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-07-05 06:40:00 UTC (rev 5592)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-07-06 14:33:04 UTC (rev 5593)
@@ -379,44 +379,10 @@
readingCommand = true;
input = readInputLine();
if (input.length() > 0) {
- // This hairy bit of code deals with shell commands that span multiple
- // input lines. If an interpreter encounters the end of the line that
- // we have given it and it requires more input to get a complete command,
- // it may throw IncompleteCommandException. The shell responds by
- // outputting a different prompt (supplied in the exception), and then
- // attempting to get the next line. If that succeeds, the line is
- // appended to the input we gave the interpreter last time, and the
- // interpreter is called again. This continues until either the
- // interpreter manages to run the command, or we get some other
- // shell syntax exception.
- boolean done = false;
- do {
- try {
- runCommand(input, true, this.interpreter);
- done = true;
- } catch (IncompleteCommandException ex) {
- String continuation = null;
- // (Tell completer to use command history not app. history)
- readingCommand = true;
- if (this.interpreter.supportsMultilineCommands()) {
- String prompt = ex.getPrompt();
- if (prompt != null) {
- outPW.print(prompt);
- }
- continuation = readInputLine();
- }
- if (continuation == null) {
- diagnose(ex, null);
- break;
- } else {
- input = input + "\n" + continuation;
- }
- } catch (ShellException ex) {
- diagnose(ex, null);
- done = true;
- }
- } while (!done);
+ runCommand(input, true, this.interpreter);
}
+ } catch (ShellException ex) {
+ diagnose(ex, null);
} catch (VmExit ex) {
// This should only happen if the interpreter wants the shell to
// exit. The interpreter will typically intercept any VmExits
@@ -427,6 +393,7 @@
+ ex.getMessage());
stackTrace(ex);
} finally {
+ // FIXME ...
if (input != null && input.trim().length() > 0) {
String lines[] = input.split("\\n");
for (String line : lines) {
@@ -564,8 +531,8 @@
}
}
- private int runCommand(String cmdLineStr, boolean interactive,
- CommandInterpreter interpreter) throws ShellException {
+ private int runCommand(String command, boolean interactive, CommandInterpreter interpreter)
+ throws ShellException {
try {
if (interactive) {
clearEof();
@@ -574,7 +541,7 @@
// for input completion
applicationHistory.set(new InputHistory());
}
- return interpreter.interpret(this, cmdLineStr);
+ return interpreter.interpret(this, new StringReader(command), null, null);
} finally {
if (interactive) {
applicationHistory.set(null);
Modified: trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-07-05 06:40:00 UTC (rev 5592)
+++ trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-07-06 14:33:04 UTC (rev 5593)
@@ -89,20 +89,11 @@
public String getName() {
return "default";
}
-
- @Override
- public int interpret(CommandShell shell, String line) throws ShellException {
- CommandLine cmd = doParseCommandLine(line);
- if (cmd == null) {
- return 0;
- }
- return shell.invoke(cmd, null, null);
- }
-
+
/**
* {@inheritDoc}
*
- * The default interpreter and its subtypes treat a command script as a sequence of commands.
+ * The default interpreter treats a command script as a sequence of commands.
* Commands are expected to consist of exactly one line. Any line whose first non-whitespace
* character is '#' will be ignored. Command line arguments from the script are not supported,
* and will result in a {@link ShellException} being thrown.
@@ -167,6 +158,15 @@
return false;
}
+ protected int interpret(CommandShell shell, String line)
+ throws ShellException {
+ CommandLine cmd = doParseCommandLine(line);
+ if (cmd == null) {
+ return 0;
+ }
+ return shell.invoke(cmd, null, null);
+ }
+
private CommandLine doParseCommandLine(String line) throws ShellException {
Tokenizer tokenizer = new Tokenizer(line);
if (!tokenizer.hasNext()) {
Modified: trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-07-05 06:40:00 UTC (rev 5592)
+++ trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-07-06 14:33:04 UTC (rev 5593)
@@ -68,7 +68,7 @@
}
@Override
- public int interpret(CommandShell shell, String line) throws ShellException {
+ protected int interpret(CommandShell shell, String line) throws ShellException {
Tokenizer tokenizer = new Tokenizer(line, REDIRECTS_FLAG);
List<CommandDescriptor> commands = new LinkedList<CommandDescriptor>();
parse(tokenizer, commands, false);
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-05 06:40:00 UTC (rev 5592)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-06 14:33:04 UTC (rev 5593)
@@ -53,7 +53,6 @@
import org.jnode.shell.Command;
import org.jnode.shell.CommandLine;
import org.jnode.shell.CommandShell;
-import org.jnode.shell.IncompleteCommandException;
import org.jnode.shell.PathnamePattern;
import org.jnode.shell.ShellException;
import org.jnode.shell.ShellFailureException;
@@ -595,7 +594,7 @@
private StringBuffer runBacktickCommand(String commandLine) throws ShellException {
StringWriter capture = new StringWriter();
- interpreter.interpret(interpreter.getShell(), commandLine, capture, false);
+ interpreter.interpret(interpreter.getShell(), new StringReader(commandLine), capture, false);
StringBuffer output = capture.getBuffer();
while (output.length() > 0 && output.charAt(output.length() - 1) == '\n') {
output.setLength(output.length() - 1);
@@ -1300,8 +1299,7 @@
return interpreter.getUniqueName();
}
- public BjorneToken[] substituteAliases(BjorneToken[] words)
- throws IncompleteCommandException {
+ public BjorneToken[] substituteAliases(BjorneToken[] words) throws ShellSyntaxException {
String alias = aliases.get(words[0].getText());
if (alias == null) {
return words;
@@ -1311,8 +1309,7 @@
return list.toArray(new BjorneToken[list.size()]);
}
- private void substituteAliases(List<BjorneToken> list, int pos, int depth)
- throws IncompleteCommandException {
+ private void substituteAliases(List<BjorneToken> list, int pos, int depth) throws ShellSyntaxException {
if (depth > 10) {
throw new ShellFailureException("probable cycle detected in alias expansion");
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-07-05 06:40:00 UTC (rev 5592)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-07-06 14:33:04 UTC (rev 5593)
@@ -30,7 +30,6 @@
import static org.jnode.shell.bjorne.BjorneToken.TOK_LESSAND;
import static org.jnode.shell.bjorne.BjorneToken.TOK_LESSGREAT;
-import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
@@ -45,10 +44,8 @@
import org.jnode.shell.CommandLine;
import org.jnode.shell.CommandShell;
import org.jnode.shell.Completable;
-import org.jnode.shell.IncompleteCommandException;
import org.jnode.shell.ShellException;
import org.jnode.shell.ShellFailureException;
-import org.jnode.shell.ShellInvocationException;
import org.jnode.shell.ShellSyntaxException;
import org.jnode.shell.io.CommandIO;
import org.jnode.shell.io.CommandOutput;
@@ -164,10 +161,10 @@
return "bjorne";
}
- @Override
- public int interpret(CommandShell shell, String command) throws ShellException {
+ public int interpret(CommandShell shell, Reader reader)
+ throws ShellException {
try {
- return interpret(shell, command, null, false);
+ return interpret(shell, reader, null, false);
} catch (BjorneControlException ex) {
switch (ex.getControl()) {
case BjorneInterpreter.BRANCH_EXIT:
@@ -194,7 +191,7 @@
BjorneTokenizer tokens = new BjorneTokenizer(partial);
BjorneCompleter completions = new BjorneCompleter(context);
try {
- new BjorneParser(tokens, "> ").parse(completions);
+ new BjorneParser(tokens).parse(completions);
} catch (ShellSyntaxException ex) {
// squelch both syntax and incomplete command exceptions.
}
@@ -217,7 +214,7 @@
}
}
- int interpret(CommandShell shell, String command, StringWriter capture, boolean source)
+ int interpret(CommandShell shell, Reader reader, StringWriter capture, boolean source)
throws ShellException {
BjorneContext myContext;
// FIXME ... I think there is something wrong / incomplete with the way I'm handling
@@ -229,8 +226,8 @@
myContext = new BjorneContext(this);
myContext.setIO(1, new CommandOutput(capture), true);
}
- BjorneTokenizer tokens = new BjorneTokenizer(command);
- CommandNode tree = new BjorneParser(tokens, "> ").parse();
+ BjorneTokenizer tokens = new BjorneTokenizer(reader);
+ CommandNode tree = new BjorneParser(tokens).parse();
if (tree == null) {
// An empty command line
return myContext.getLastReturnCode();
@@ -252,44 +249,27 @@
context.setCommand(alias == null ? "" : alias);
context.setArgs(args == null ? new String[0] : args);
try {
- BufferedReader br = new BufferedReader(reader);
- String line;
- int rc = 0;
- while ((line = br.readLine()) != null) {
- boolean done = false;
- do {
- try {
- rc = interpret(shell, line, null, false);
- done = true;
- } catch (BjorneControlException ex) {
- switch (ex.getControl()) {
- case BjorneInterpreter.BRANCH_EXIT:
- // The script will exit immediately
- return ex.getCount();
- case BjorneInterpreter.BRANCH_BREAK:
- throw new ShellSyntaxException(
- "'break' has been executed in an inappropriate context");
- case BjorneInterpreter.BRANCH_CONTINUE:
- throw new ShellSyntaxException(
- "'continue' has been executed in an inappropriate context");
- case BjorneInterpreter.BRANCH_RETURN:
- throw new ShellSyntaxException(
- "'return' has been executed in an inappropriate context");
- }
- } catch (IncompleteCommandException ex) {
- String continuation = br.readLine();
- if (continuation == null) {
- throw ex;
- }
- line = line + "\n" + continuation;
- } catch (VmExit ex) {
- return ex.getStatus();
- }
- } while (!done);
+ return interpret(shell, reader, null, false);
+ } catch (BjorneControlException ex) {
+ switch (ex.getControl()) {
+ case BjorneInterpreter.BRANCH_EXIT:
+ // The script will exit immediately
+ return ex.getCount();
+ case BjorneInterpreter.BRANCH_BREAK:
+ throw new ShellSyntaxException(
+ "'break' has been executed in an inappropriate context");
+ case BjorneInterpreter.BRANCH_CONTINUE:
+ throw new ShellSyntaxException(
+ "'continue' has been executed in an inappropriate context");
+ case BjorneInterpreter.BRANCH_RETURN:
+ throw new ShellSyntaxException(
+ "'return' has been executed in an inappropriate context");
+ default:
+ throw new ShellFailureException(
+ "unknown 'control' in BjorneControlException");
}
- return rc;
- } catch (IOException ex) {
- throw new ShellInvocationException("Problem reading command file: " + ex.getMessage(), ex);
+ } catch (VmExit ex) {
+ return ex.getStatus();
} finally {
if (reader != null) {
try {
@@ -318,7 +298,8 @@
Properties sysProps, Map<String, String> env, boolean isBuiltin)
throws ShellException {
if (isBuiltin) {
- BjorneBuiltinCommandInfo builtin = BUILTINS.get(cmdLine.getCommandName()).buildCommandInfo(context);
+ BjorneBuiltinCommandInfo builtin =
+ BUILTINS.get(cmdLine.getCommandName()).buildCommandInfo(context);
cmdLine.setCommandInfo(builtin);
}
cmdLine.setStreams(streams);
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-07-05 06:40:00 UTC (rev 5592)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-07-06 14:33:04 UTC (rev 5593)
@@ -107,7 +107,6 @@
import java.util.LinkedList;
import java.util.List;
-import org.jnode.shell.IncompleteCommandException;
import org.jnode.shell.ShellSyntaxException;
/**
@@ -122,14 +121,11 @@
private final BjorneTokenizer tokens;
private BjorneCompleter completer;
- private final String continuationPrompt;
-
private final List<RedirectionNode> hereRedirections = new ArrayList<RedirectionNode>();
private boolean allowLineBreaks;
- public BjorneParser(BjorneTokenizer tokens, String continuationPrompt) {
+ public BjorneParser(BjorneTokenizer tokens) {
this.tokens = tokens;
- this.continuationPrompt = continuationPrompt;
}
/**
@@ -143,6 +139,9 @@
public CommandNode parse() throws ShellSyntaxException {
hereRedirections.clear();
List<CommandNode> commands = new LinkedList<CommandNode>();
+ // (The POSIX syntax doesn't seem to allow line breaks at the start, but I
+ // don't think that can be right ...)
+ skipLineBreaks();
while (peek().getTokenType() != TOK_END_OF_STREAM) {
CommandNode command = parseList();
commands.add(command);
@@ -344,12 +343,6 @@
// FIXME ... built-in commands should use the Syntax mechanisms so
// that completion, help, etc will work as expected.
}
- } catch (IncompleteCommandException ex) {
- if (completer != null) {
- completer.setCommand(new SimpleCommandNode(CMD_COMMAND,
- words.toArray(new BjorneToken[words.size()]), builtin));
- }
- throw ex;
} catch (ShellSyntaxException ex) {
if (completer != null) {
completer.setCommand(words.size() == 0 ? null :
@@ -693,21 +686,21 @@
return token;
}
- private BjorneToken next() throws IncompleteCommandException {
+ private BjorneToken next() throws ShellSyntaxException {
if (allowLineBreaks) {
doLineBreaks(0L, false);
}
return tokens.next();
}
- private BjorneToken peek() throws IncompleteCommandException {
+ private BjorneToken peek() throws ShellSyntaxException {
if (allowLineBreaks) {
doLineBreaks(0L, false);
}
return tokens.peek();
}
- private BjorneToken peekEager() throws IncompleteCommandException {
+ private BjorneToken peekEager() throws ShellSyntaxException {
if (allowLineBreaks) {
doLineBreaks(0L, true);
}
@@ -721,9 +714,8 @@
if (((1L << tt) & expectedSet) == 0L) {
if (mandatory) {
if (tt == TOK_END_OF_STREAM) {
- throw new IncompleteCommandException(
- "EOF reached while looking for " + BjorneToken.formatExpectedSet(expectedSet),
- continuationPrompt);
+ throw new ShellSyntaxException(
+ "EOF reached while looking for " + BjorneToken.formatExpectedSet(expectedSet));
} else {
throw new ShellSyntaxException(
"expected " + BjorneToken.formatExpectedSet(expectedSet) + " but got " + token);
@@ -765,16 +757,16 @@
}
}
- private void skipLineBreaks() throws IncompleteCommandException {
+ private void skipLineBreaks() throws ShellSyntaxException {
this.allowLineBreaks = true;
doLineBreaks(0L, false);
}
- private void allowLineBreaks() throws IncompleteCommandException {
+ private void allowLineBreaks() throws ShellSyntaxException {
this.allowLineBreaks = true;
}
- private void doLineBreaks(long expectedSet, boolean needMore) throws IncompleteCommandException {
+ private void doLineBreaks(long expectedSet, boolean needMore) throws ShellSyntaxException {
// NB: use tokens.peek() / next() rather than the wrappers here!!
this.allowLineBreaks = false;
BjorneToken token = tokens.peek();
@@ -782,9 +774,8 @@
if (tt == TOK_END_OF_STREAM) {
captureCompletions(token, expectedSet);
if (needMore) {
- throw new IncompleteCommandException(
- "EOF reached while looking for optional linebreak(s)",
- continuationPrompt);
+ throw new ShellSyntaxException(
+ "EOF reached while looking for optional linebreak(s)");
}
} else if (tt == TOK_END_OF_LINE) {
tokens.next();
@@ -797,9 +788,8 @@
} else if (tt == TOK_END_OF_STREAM) {
captureCompletions(token, expectedSet);
if (needMore) {
- throw new IncompleteCommandException(
- "EOF reached while dealing with optional linebreak(s)",
- continuationPrompt);
+ throw new ShellSyntaxException(
+ "EOF reached while dealing with optional linebreak(s)");
} else {
break;
}
@@ -810,7 +800,7 @@
}
}
- private void captureHereDocuments() throws IncompleteCommandException {
+ private void captureHereDocuments() throws ShellSyntaxException {
for (RedirectionNode redirection : hereRedirections) {
StringBuilder sb = new StringBuilder();
String marker = redirection.getArg().getText();
@@ -818,8 +808,8 @@
while (true) {
String line = tokens.readHereLine(trimTabs);
if (line == null) {
- throw new IncompleteCommandException("EOF reached while looking for '" +
- marker + "' to end a HERE document", continuationPrompt);
+ throw new ShellSyntaxException("EOF reached while looking for '" +
+ marker + "' to end a HERE document");
}
if (line.equals(marker)) {
break;
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-07-05 06:40:00 UTC (rev 5592)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-07-06 14:33:04 UTC (rev 5593)
@@ -66,92 +66,58 @@
import static org.jnode.shell.bjorne.BjorneToken.TOK_WHILE;
import static org.jnode.shell.bjorne.BjorneToken.TOK_WORD;
-import org.jnode.shell.IncompleteCommandException;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+
import org.jnode.shell.ShellFailureException;
+import org.jnode.shell.ShellSyntaxException;
public class BjorneTokenizer {
- private final char[] chars;
+ private final Reader reader;
- private final int len;
-
- private int pos;
-
private BjorneToken prev, current, next;
-
private static final int EOS = -1;
+ private static final int INVALID = -2;
+
+ private int pos = 0;
+ private int lastCh = INVALID;
+ private int nextCh = INVALID;
private final boolean debug;
/**
* Create a tokenizer for the supplied shell input text.
* @param text the text to be tokenized
- * @throws IncompleteCommandException if the text ends with a line continuation
+ * @throws ShellSyntaxException
*/
- public BjorneTokenizer(String text) throws IncompleteCommandException {
- this(text, false);
+ public BjorneTokenizer(String text)
+ throws ShellSyntaxException {
+ this(new StringReader(text), false);
}
/**
- * Create a tokenizer for the supplied shell input text.
- * @param text the text to be tokenized
- * @param debug if {@code true}, produce debug output
- * @throws IncompleteCommandException if the text ends with a line continuation
+ * Create a tokenizer for the supplied shell input reader.
+ * @param reader the reader to be tokenized.
+ * @throws ShellSyntaxException
*/
- public BjorneTokenizer(String text, boolean debug) throws IncompleteCommandException {
- chars = foldContinuations(text);
- len = chars.length;
- this.debug = debug;
+ public BjorneTokenizer(Reader reader)
+ throws ShellSyntaxException {
+ this(reader, false);
}
/**
- * Rewrite the supplied text to fold any line continuations.
- *
- * @param text the text to be processed
- * @return the characters of text with any line continuations removed.
- * @throws IncompleteCommandException
+ * Create a tokenizer for the supplied shell input text.
+ * @param reader the reader to be tokenized.
+ * @param debug if {@code true}, produce debug output
+ * @throws ShellSyntaxException
*/
- private char[] foldContinuations(String text) throws IncompleteCommandException {
- // FIXME this is wrong ... if we are going to imitate the documented behaviour
- // of bash. (In bash, if the the MARKER is quoted, '\<newline>' is apparently
- // not interpreted as a continuation.)
- if (text.indexOf('\\') == -1) {
- return text.toCharArray();
- }
- int len = text.length();
- StringBuilder sb = new StringBuilder(len);
- boolean escape = false;
- for (int i = 0; i < len; i++) {
- char ch = text.charAt(i);
- switch (ch) {
- case '\\':
- if (escape) {
- sb.append('\\');
- } else if (i == len - 1) {
- // If we get a continuation sequence at the end of the
- // text, the simplest thing is to ask for more input.
- throw new IncompleteCommandException(
- "More input required after '\\<newline>'", " > ");
- }
- escape = !escape;
- break;
- case '\n':
- if (!escape) {
- sb.append('\n');
- } else {
- escape = false;
- }
- break;
- default:
- if (escape) {
- sb.append('\\');
- escape = false;
- }
- sb.append(ch);
- }
- }
- return sb.toString().toCharArray();
+ public BjorneTokenizer(Reader reader, boolean debug)
+ throws ShellSyntaxException {
+ this.reader = reader;
+ this.debug = debug;
}
/**
@@ -180,7 +146,7 @@
public BjorneToken peek(int context) {
BjorneToken res = reinterpret(peek(), context);
if (debug) {
- System.err.println("--> " + res);
+ System.err.println("peek(" + context + ") --> " + res);
}
return res;
}
@@ -240,7 +206,7 @@
public BjorneToken next(int context) {
BjorneToken res = reinterpret(next(), context);
if (debug) {
- System.err.println("--> " + res);
+ System.err.println("next(" + context + ") --> " + res);
}
return res;
}
@@ -290,15 +256,17 @@
System.err.print("advance() ... {" + prev + "," + ...
[truncated message content] |
|
From: <cr...@us...> - 2009-07-07 14:20:34
|
Revision: 5598
http://jnode.svn.sourceforge.net/jnode/?rev=5598&view=rev
Author: crawley
Date: 2009-07-07 14:07:37 +0000 (Tue, 07 Jul 2009)
Log Message:
-----------
Implement special handling of quoting in HERE document markers.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java
trunk/shell/src/shell/org/jnode/shell/bjorne/RedirectionNode.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-07 10:50:37 UTC (rev 5597)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-07 14:07:37 UTC (rev 5598)
@@ -423,40 +423,55 @@
return wordTokens;
}
+ /**
+ * Do quote removal on a list of tokens
+ *
+ * @param wordTokens the tokens to be processed.
+ * @return the de-quoted tokens
+ */
private List<BjorneToken> dequote(List<BjorneToken> wordTokens) {
List<BjorneToken> resTokens = new LinkedList<BjorneToken>();
for (BjorneToken token : wordTokens) {
- String text = token.getText();
- int len = text.length();
- StringBuffer sb = new StringBuffer(len);
- int quote = 0;
- for (int i = 0; i < len; i++) {
- char ch = text.charAt(i);
- switch (ch) {
- case '"':
- case '\'':
- if (quote == 0) {
- quote = ch;
- } else if (quote == ch) {
- quote = 0;
- } else {
- sb.append(ch);
- }
- break;
- case '\\':
- if (i + 1 < len) {
- ch = text.charAt(++i);
- }
+ resTokens.add(token.remake(dequote(token.getText())));
+ }
+ return resTokens;
+ }
+
+ /**
+ * Do quote removal on a String
+ *
+ * @param text the text to be processed.
+ * @return the de-quoted text
+ */
+ static StringBuffer dequote(String text) {
+ int len = text.length();
+ StringBuffer sb = new StringBuffer(len);
+ int quote = 0;
+ for (int i = 0; i < len; i++) {
+ char ch = text.charAt(i);
+ switch (ch) {
+ case '"':
+ case '\'':
+ if (quote == 0) {
+ quote = ch;
+ } else if (quote == ch) {
+ quote = 0;
+ } else {
sb.append(ch);
- break;
- default:
- sb.append(ch);
- break;
- }
+ }
+ break;
+ case '\\':
+ if (i + 1 < len) {
+ ch = text.charAt(++i);
+ }
+ sb.append(ch);
+ break;
+ default:
+ sb.append(ch);
+ break;
}
- resTokens.add(token.remake(sb));
}
- return resTokens;
+ return sb;
}
/**
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-07-07 10:50:37 UTC (rev 5597)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-07-07 14:07:37 UTC (rev 5598)
@@ -766,6 +766,12 @@
this.allowLineBreaks = true;
}
+ /**
+ * Skip optional linebreaks.
+ * @param expectedSet the tokens expected after the line breaks
+ * @param needMore if {@code true} we need a token after the line breaks,
+ * otherwise, it is OK to have no more tokens.
+ */
private void doLineBreaks(long expectedSet, boolean needMore) throws ShellSyntaxException {
// NB: use tokens.peek() / next() rather than the wrappers here!!
this.allowLineBreaks = false;
@@ -800,23 +806,40 @@
}
}
+ /**
+ * Capture all current HERE documents, dealing with TAB stripping (if required)
+ * and recording on the relevant redirection object. We don't do expansions at
+ * this point, but we set the flag to say if expansion is required.
+ *
+ * @throws ShellSyntaxException
+ */
private void captureHereDocuments() throws ShellSyntaxException {
for (RedirectionNode redirection : hereRedirections) {
StringBuilder sb = new StringBuilder();
- String marker = redirection.getArg().getText();
+ String rawMarker = redirection.getArg().getText();
+ String marker = BjorneContext.dequote(rawMarker).toString();
boolean trimTabs = redirection.getRedirectionType() == TOK_DLESSDASH;
while (true) {
- String line = tokens.readHereLine(trimTabs);
+ String line = tokens.readRawLine();
if (line == null) {
throw new ShellSyntaxException("EOF reached while looking for '" +
marker + "' to end a HERE document");
}
+ if (trimTabs) {
+ int len = line.length();
+ int i;
+ for (i = 0; i < len && line.charAt(i) == '\t'; i++) { /**/ }
+ if (i > 0) {
+ line = line.substring(i);
+ }
+ }
if (line.equals(marker)) {
break;
}
sb.append(line).append('\n');
}
redirection.setHereDocument(sb.toString());
+ redirection.setHereDocumentExpandable(marker.equals(rawMarker));
}
hereRedirections.clear();
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-07-07 10:50:37 UTC (rev 5597)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-07-07 14:07:37 UTC (rev 5598)
@@ -222,11 +222,10 @@
* This method bypasses normal tokenization and reads a raw line of
* text up to the next NL (or the end of stream).
*
- * @param trimTabs if {@code true}, trim any leading TABs from the line
* @return the line read without the terminating NL. If we got an
* end of stream immediately, return {@code null}.
*/
- public String readHereLine(boolean trimTabs) {
+ public String readRawLine() {
StringBuilder sb = new StringBuilder(40);
while (true) {
int ch = nextCh();
@@ -235,11 +234,6 @@
return sb.toString();
case EOS:
return (sb.length() > 0) ? sb.toString() : null;
- case '\t':
- if (!trimTabs || sb.length() > 0) {
- sb.append('\t');
- }
- break;
default:
sb.append((char) ch);
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/RedirectionNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/RedirectionNode.java 2009-07-07 10:50:37 UTC (rev 5597)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/RedirectionNode.java 2009-07-07 14:07:37 UTC (rev 5598)
@@ -31,8 +31,7 @@
private boolean expandable = true;
- public RedirectionNode(final int redirectionType, BjorneToken io,
- BjorneToken arg) {
+ public RedirectionNode(final int redirectionType, BjorneToken io, BjorneToken arg) {
super();
this.redirectionType = redirectionType;
this.io = io;
@@ -78,4 +77,9 @@
public boolean isHereDocumentExpandable() {
return expandable;
}
+
+ public void setHereDocumentExpandable(boolean expandable) {
+ this.expandable = expandable;
+ }
+
}
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-07-07 10:50:37 UTC (rev 5597)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-07-07 14:07:37 UTC (rev 5598)
@@ -735,6 +735,19 @@
Hi mum 5
</output>
</testSpec>
+ <testSpec title="here 4" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ for i in 1 2 3 4 5 ; do cat << "EOF" ; done
+Hi mum `echo $i`
+EOF
+ </script>
+ <output>Hi mum `echo $i`
+Hi mum `echo $i`
+Hi mum `echo $i`
+Hi mum `echo $i`
+Hi mum `echo $i`
+</output>
+ </testSpec>
<testSpec title="pipeline" command="test" runMode="AS_SCRIPT" rc="0">
<script>#!bjorne
echo > @TEMP_DIR@/1 Hi mum
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-07-14 14:06:26
|
Revision: 5607
http://jnode.svn.sourceforge.net/jnode/?rev=5607&view=rev
Author: crawley
Date: 2009-07-14 14:06:25 +0000 (Tue, 14 Jul 2009)
Log Message:
-----------
Remove deprecated methods
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/CommandShell.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-07-14 13:45:58 UTC (rev 5606)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-07-14 14:06:25 UTC (rev 5607)
@@ -995,20 +995,6 @@
return syntaxMgr;
}
- /**
- * @deprecated Don't use this method. I intend to get rid of it.
- */
- public PrintWriter getOut() {
- return outPW;
- }
-
- /**
- * @deprecated Don't use this method. I intend to get rid of it.
- */
- public PrintWriter getErr() {
- return errPW;
- }
-
@Override
public void addConsoleOuputRecorder(Writer writer) {
// FIXME do security check
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java 2009-07-14 13:45:58 UTC (rev 5606)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java 2009-07-14 14:06:25 UTC (rev 5607)
@@ -22,7 +22,6 @@
import java.io.InputStream;
import java.io.PrintStream;
-import java.io.PrintWriter;
import org.jnode.shell.CommandLine;
import org.jnode.shell.CommandShell;
@@ -56,16 +55,6 @@
}
@Override
- public PrintWriter getErr() {
- return cerr.getPrintWriter(true);
- }
-
- @Override
- public PrintWriter getOut() {
- return cout.getPrintWriter(false);
- }
-
- @Override
protected CommandIO resolveStream(CommandIO stream) {
if (stream == CommandLine.DEFAULT_STDIN) {
return cin;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-07-22 14:42:33
|
Revision: 5618
http://jnode.svn.sourceforge.net/jnode/?rev=5618&view=rev
Author: crawley
Date: 2009-07-22 14:42:31 +0000 (Wed, 22 Jul 2009)
Log Message:
-----------
Improvements to bjorne's command history and prompt handling. (Bjorne
now uses PS1 and PS2.)
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java
trunk/shell/src/shell/org/jnode/shell/CommandShell.java
trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java
trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
trunk/shell/src/test/org/jnode/test/shell/CompletionHelper.java
trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java
trunk/shell/src/test/org/jnode/test/shell/DefaultSyntaxCompletionTest.java
Removed Paths:
-------------
trunk/shell/src/shell/org/jnode/shell/MultilineInterpreter.java
Modified: trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -86,8 +86,24 @@
* @return the word with any necessary escaping or quoting added.
*/
String escapeWord(String word);
+
+ /**
+ * Test if the interpreter supports multiline commands.
+ *
+ * @return {@code true} if the interpreter supports multiline commands.
+ */
+ boolean supportsMultiline();
/**
+ * Get the command prompt.
+ *
+ * @param shell the shell that is supplying command input.
+ * @param continuation {@code true} if the interpreter is expecting a continuation line.
+ * @return the command prompt
+ */
+ String getPrompt(CommandShell shell, boolean continuation);
+
+ /**
* Get incremental help for the partial command line. If the interpreter
* does not support incremental help, it should simply return <code>false</code>.
*
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -35,8 +35,6 @@
import java.io.Writer;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.text.DateFormat;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -142,12 +140,12 @@
private SyntaxManager syntaxMgr;
/**
- * Keeps a reference to the console this CommandShell is using *
+ * Keeps a reference to the console this CommandShell is using.
*/
private TextConsole console;
/**
- * Contains the archive of commands. *
+ * Contains the archive of commands.
*/
private InputHistory commandHistory = new InputHistory();
@@ -158,7 +156,9 @@
new InheritableThreadLocal<InputHistory>();
/**
- * When true, {@link complete(String)} performs command completion.
+ * When {@code true}, command input characters are being requested / read
+ * from the console. This controls whether command or application history
+ * is used, and whether command completion may be active.
*/
private boolean readingCommand;
@@ -274,7 +274,6 @@
new InputStreamReader(System.in),
new OutputStreamWriter(System.out),
new OutputStreamWriter(System.err));
- this.readingCommand = true;
}
@@ -321,7 +320,6 @@
try {
if (e.startsWith(COMMAND_KEY)) {
final String cmd = e.substring(COMMAND_KEY.length());
- outPW.println(prompt() + cmd);
runCommand(cmd);
}
} catch (Throwable ex) {
@@ -372,25 +370,17 @@
});
while (!isExited() && !VmSystem.isShuttingDown()) {
- String input = null;
CommandShellReader reader = null;
try {
clearEof();
- outPW.print(prompt());
- readingCommand = true;
- input = readInputLine();
- if (input.length() > 0) {
- try {
- clearEof();
- readingCommand = false;
- // Each interactive command is launched with a fresh history
- // for input completion
- applicationHistory.set(new InputHistory());
- reader = new CommandShellReader(input, interpreter, outPW, in);
- interpreter.interpret(this, reader, false, null, null);
- } finally {
- applicationHistory.set(null);
- }
+ try {
+ // Each interactive command is launched with a fresh history
+ // for input completion
+ applicationHistory.set(new InputHistory());
+ reader = new CommandShellReader(this, interpreter, outPW, in);
+ interpreter.interpret(this, reader, false, null, null);
+ } finally {
+ applicationHistory.set(null);
}
} catch (ShellException ex) {
diagnose(ex, null);
@@ -403,6 +393,11 @@
errPW.println("Uncaught exception while processing command(s): "
+ ex.getMessage());
stackTrace(ex);
+ try {
+ Thread.sleep(100000);
+ } catch (InterruptedException ex2) {
+
+ }
} finally {
if (reader != null) {
for (String line : reader.getLines()) {
@@ -449,6 +444,10 @@
ownThread = Thread.currentThread();
}
+ protected void setReadingCommand(boolean readingCommand) {
+ this.readingCommand = readingCommand;
+ }
+
@Override
public String getProperty(String propName) {
return propertyMap.get(propName);
@@ -522,18 +521,7 @@
ex.printStackTrace(errPW);
}
}
-
- private String readInputLine() throws IOException {
- StringBuffer sb = new StringBuffer(40);
- while (true) {
- int ch = in.read();
- if (ch == -1 || ch == '\n') {
- return sb.toString();
- }
- sb.append((char) ch);
- }
- }
-
+
private void clearEof() {
if (in instanceof KeyboardReader) {
((KeyboardReader) in).clearSoftEOF();
@@ -660,51 +648,6 @@
return CommandShell.applicationHistory.get();
}
}
-
- /**
- * Gets the expanded prompt
- */
- protected String prompt() {
- String prompt = getProperty(PROMPT_PROPERTY_NAME);
- final StringBuffer result = new StringBuffer();
- boolean commandMode = false;
- try {
- StringReader reader = new StringReader(prompt);
- int i;
- while ((i = reader.read()) != -1) {
- char c = (char) i;
- if (commandMode) {
- switch (c) {
- case 'P':
- result.append(new File(System.getProperty(DIRECTORY_PROPERTY_NAME, "")));
- break;
- case 'G':
- result.append("> ");
- break;
- case 'D':
- final Date now = new Date();
- DateFormat.getDateTimeInstance().format(now, result, null);
- break;
- default:
- result.append(c);
- }
- commandMode = false;
- } else {
- switch (c) {
- case '$':
- commandMode = true;
- break;
- default:
- result.append(c);
- }
- }
- }
- } catch (Exception ioex) {
- // This should never occur
- log.error("Error in prompt()", ioex);
- }
- return result.toString();
- }
/**
* This method is called by the console input driver to perform command line
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -37,28 +37,34 @@
private StringReader reader;
private final Reader in;
private final PrintWriter out;
- private final MultilineInterpreter interpreter;
+ private final CommandShell shell;
+ private final CommandInterpreter interpreter;
private final List<String> lines = new ArrayList<String>(1);
- public CommandShellReader(String command, CommandInterpreter interpreter, PrintWriter out, Reader in) {
- this.interpreter = (interpreter instanceof MultilineInterpreter) ?
- (MultilineInterpreter) interpreter : null;
-
- this.lines.add(command);
- if (interpreter != null) {
- command += "\n";
- }
- this.reader = new StringReader(command);
+ public CommandShellReader(CommandShell shell, CommandInterpreter interpreter,
+ PrintWriter out, Reader in)
+ throws IOException {
+ this.shell = shell;
+ this.interpreter = interpreter;
this.out = out;
this.in = in;
+ nextReader(true);
}
- private boolean nextReader() throws IOException {
- if (interpreter != null) {
- String prompt = interpreter.getContinuationPrompt();
- out.print(prompt);
- out.flush();
- StringBuilder sb = new StringBuilder(40);
+ private boolean nextReader(boolean first) throws IOException {
+ String prompt;
+ if (first) {
+ prompt = interpreter.getPrompt(shell, false);
+ } else if (interpreter.supportsMultiline()) {
+ prompt = interpreter.getPrompt(shell, true);
+ } else {
+ return false;
+ }
+ out.print(prompt);
+ out.flush();
+ StringBuilder sb = new StringBuilder(40);
+ try {
+ shell.setReadingCommand(true);
while (true) {
int ch = in.read();
if (ch == -1) {
@@ -72,22 +78,22 @@
sb.append((char) ch);
}
}
- this.lines.add(sb.toString());
- sb.append('\n');
- reader = new StringReader(sb.toString());
- return true;
- } else {
- return false;
+ } finally {
+ shell.setReadingCommand(false);
}
+ this.lines.add(sb.toString());
+ sb.append('\n');
+ reader = new StringReader(sb.toString());
+ return true;
}
@Override
public int read() throws IOException {
if (reader == null) {
- throw new IOException("CommandShellReader is closed");
+ return -1;
}
int res = reader.read();
- if (res == -1 && nextReader()) {
+ if (res == -1 && nextReader(false)) {
res = reader.read();
}
return res;
@@ -111,10 +117,10 @@
@Override
public int read(char[] cbuf, int off, int len) throws IOException {
if (reader == null) {
- throw new IOException("CommandShellReader is closed");
+ return -1;
}
int res = reader.read(cbuf, off, len);
- if (res == 0 && nextReader()) {
+ if (res == 0 && nextReader(false)) {
res = reader.read(cbuf, off, len);
}
return res;
@@ -128,10 +134,10 @@
@Override
public int read(CharBuffer target) throws IOException {
if (reader == null) {
- throw new IOException("CommandShellReader is closed");
+ return -1;
}
int res = reader.read(target);
- if (res == 0 && nextReader()) {
+ if (res == 0 && nextReader(false)) {
res = reader.read(target);
}
return res;
@@ -140,9 +146,9 @@
@Override
public boolean ready() throws IOException {
if (reader == null) {
- throw new IOException("CommandShellReader is closed");
+ return false;
}
- return true;
+ return reader.ready();
}
@Override
Modified: trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -21,10 +21,14 @@
package org.jnode.shell;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Reader;
+import java.io.StringReader;
+import java.text.DateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.LinkedList;
import java.util.NoSuchElementException;
@@ -247,6 +251,56 @@
}
/**
+ * Get and expand the default command prompt.
+ */
+ public String getPrompt(CommandShell shell, boolean continuation) {
+ String prompt = shell.getProperty(CommandShell.PROMPT_PROPERTY_NAME);
+ final StringBuffer result = new StringBuffer();
+ boolean commandMode = false;
+ StringReader reader = new StringReader(prompt);
+ int i;
+ try {
+ while ((i = reader.read()) != -1) {
+ char c = (char) i;
+ if (commandMode) {
+ switch (c) {
+ case 'P':
+ result.append(new File(System.getProperty(CommandShell.DIRECTORY_PROPERTY_NAME, "")));
+ break;
+ case 'G':
+ result.append("> ");
+ break;
+ case 'D':
+ final Date now = new Date();
+ DateFormat.getDateTimeInstance().format(now, result, null);
+ break;
+ default:
+ result.append(c);
+ }
+ commandMode = false;
+ } else {
+ switch (c) {
+ case '$':
+ commandMode = true;
+ break;
+ default:
+ result.append(c);
+ }
+ }
+ }
+ } catch (IOException ex) {
+ // A StringReader shouldn't give an IOException unless we close it ... which we don't!
+ LOG.error("Impossible", ex);
+ }
+ return result.toString();
+ }
+
+ @Override
+ public boolean supportsMultiline() {
+ return false;
+ }
+
+ /**
* A simple command line tokenizer for the 'built-in' interpreters. It
* understands quoting, some '\' escapes, and (depending on constructor
* flags) certain "special" symbols.
Deleted: trunk/shell/src/shell/org/jnode/shell/MultilineInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/MultilineInterpreter.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/shell/org/jnode/shell/MultilineInterpreter.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -1,26 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2003-2009 JNode.org
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-package org.jnode.shell;
-
-public interface MultilineInterpreter extends CommandInterpreter {
-
- public String getContinuationPrompt();
-}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -136,6 +136,7 @@
this.holders = holders;
this.variables = new HashMap<String, VariableSlot>();
this.aliases = new TreeMap<String, String>();
+ initVariables();
}
public BjorneContext(BjorneInterpreter interpreter) {
@@ -151,6 +152,12 @@
return res;
}
+ private void initVariables() {
+ setVariable("PS1", "$ ");
+ setVariable("PS2", "> ");
+ setVariable("PS4", "+ ");
+ }
+
/**
* Create a copy of a context with the same initial variable bindings and
* streams. Stream ownership is not transferred.
@@ -1355,4 +1362,15 @@
public Collection<String> getVariableNames() {
return variables.keySet();
}
+
+ public String getVariable(String name) {
+ VariableSlot slot = variables.get(name);
+ if (slot == null) {
+ return "";
+ } else if (slot.getValue() == null) {
+ return "";
+ } else {
+ return slot.getValue();
+ }
+ }
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -40,10 +40,10 @@
import java.util.Map;
import java.util.Properties;
+import org.jnode.shell.CommandInterpreter;
import org.jnode.shell.CommandLine;
import org.jnode.shell.CommandShell;
import org.jnode.shell.Completable;
-import org.jnode.shell.MultilineInterpreter;
import org.jnode.shell.ShellException;
import org.jnode.shell.ShellFailureException;
import org.jnode.shell.ShellSyntaxException;
@@ -57,7 +57,7 @@
*
* @author cr...@jn...
*/
-public class BjorneInterpreter implements MultilineInterpreter {
+public class BjorneInterpreter implements CommandInterpreter {
public static final int CMD_EMPTY = 0;
@@ -218,7 +218,6 @@
do {
CommandNode tree = parser.parse();
if (tree == null) {
- // end of file ...
break;
}
if (DEBUG) {
@@ -271,10 +270,21 @@
}
@Override
- public String getContinuationPrompt() {
- return parser == null ? null : parser.getContinuationPrompt();
+ public String getPrompt(CommandShell shell, boolean continuation) {
+ String res = context.getVariable(continuation ? "PS2" : "PS1");
+ return (res == null) ? "$ " : expandPrompt(res);
}
+ private String expandPrompt(String prompt) {
+ // FIXME implement
+ return prompt;
+ }
+
+ @Override
+ public boolean supportsMultiline() {
+ return true;
+ }
+
private void bindShell(CommandShell shell) {
if (this.shell != shell) {
if (this.shell != null) {
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -138,13 +138,16 @@
*/
public CommandNode parse() throws ShellSyntaxException {
hereRedirections.clear();
- CommandNode command = null;
- // (The POSIX syntax doesn't seem to allow line breaks at the start, but I
- // don't think that can be right ...)
- skipLineBreaks();
- command = parseOptList();
- allowLineBreaks();
- captureHereDocuments();
+ CommandNode command = parseOptList();
+ if (command != null) {
+ allowLineBreaks();
+ captureHereDocuments();
+ } else {
+ noLineBreaks();
+ if (optNext(TOK_END_OF_LINE_BIT) != null) {
+ command = new SimpleCommandNode(CMD_COMMAND, new BjorneToken[0], false);
+ }
+ }
return command;
}
@@ -221,7 +224,7 @@
}
private CommandNode parseOptAndOr() throws ShellSyntaxException {
- allowLineBreaks();
+ // allowLineBreaks();
if (optPeek(TOK_LBRACE_BIT | TOK_LPAREN_BIT | TOK_COMMAND_NAME_BITS | TOK_FUNCTION_NAME_BITS |
TOK_IF_BIT | TOK_WHILE_BIT | TOK_UNTIL_BIT | TOK_CASE_BIT | TOK_FOR_BIT |
TOK_IO_NUMBER_BIT | TOK_LESS_BIT | TOK_GREAT_BIT | TOK_DLESS_BIT |
@@ -756,6 +759,10 @@
this.allowLineBreaks = true;
}
+ private void noLineBreaks() throws ShellSyntaxException {
+ this.allowLineBreaks = false;
+ }
+
/**
* Skip optional linebreaks.
* @param expectedSet the tokens expected after the line breaks
Modified: trunk/shell/src/test/org/jnode/test/shell/CompletionHelper.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/CompletionHelper.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/test/org/jnode/test/shell/CompletionHelper.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -28,6 +28,8 @@
import org.jnode.driver.console.CompletionInfo;
import org.jnode.shell.CommandShell;
+import org.jnode.test.shell.syntax.TestAliasManager;
+import org.jnode.test.shell.syntax.TestSyntaxManager;
/**
* Helper methods for doing completion tests.
@@ -35,8 +37,21 @@
* @author cr...@jn...
*/
public class CompletionHelper {
+
+ public static class TestCommandShell extends CommandShell {
+
+ protected TestCommandShell(TestAliasManager testAliasManager,
+ TestSyntaxManager testSyntaxManager) {
+ super(testAliasManager, testSyntaxManager);
+ }
- public static void checkCompletions(CommandShell cs, String line, String[] expected, int startPos) {
+ public void setReadingCommand(boolean readingCommand) {
+ super.setReadingCommand(readingCommand);
+ }
+ }
+
+ public static void checkCompletions(TestCommandShell cs, String line, String[] expected, int startPos) {
+ cs.setReadingCommand(true);
CompletionInfo ci = cs.complete(line);
SortedSet<String> completions = ci.getCompletions();
if (completions.size() != expected.length) {
Modified: trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -96,9 +96,9 @@
System.setProperty("user.dir", userDirName);
}
- public class TestCommandShell extends CommandShell {
+ public class MyTestCommandShell extends CompletionHelper.TestCommandShell {
- public TestCommandShell() throws NameNotFoundException {
+ public MyTestCommandShell() throws NameNotFoundException {
super(new TestAliasManager(), new TestSyntaxManager());
ShellUtils.getShellManager().registerShell(this);
@@ -132,7 +132,7 @@
}
public void testDefaultInterpreterNewSyntax() throws Exception {
- TestCommandShell cs = new TestCommandShell();
+ MyTestCommandShell cs = new MyTestCommandShell();
cs.setProperty(CommandShell.INTERPRETER_PROPERTY_NAME, "default");
final String[] propertyCompletions = getExpectedPropertyNameCompletions();
Modified: trunk/shell/src/test/org/jnode/test/shell/DefaultSyntaxCompletionTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/DefaultSyntaxCompletionTest.java 2009-07-22 13:28:52 UTC (rev 5617)
+++ trunk/shell/src/test/org/jnode/test/shell/DefaultSyntaxCompletionTest.java 2009-07-22 14:42:31 UTC (rev 5618)
@@ -90,9 +90,9 @@
System.setProperty("user.dir", userDirName);
}
- public class TestCommandShell extends CommandShell {
+ public class MyTestCommandShell extends CompletionHelper.TestCommandShell {
- public TestCommandShell() throws NameNotFoundException {
+ public MyTestCommandShell() throws NameNotFoundException {
super(new TestAliasManager(), new TestSyntaxManager());
ShellUtils.getShellManager().registerShell(this);
@@ -114,7 +114,7 @@
}
public void testDefaultSyntax() throws Exception {
- TestCommandShell cs = new TestCommandShell();
+ MyTestCommandShell cs = new MyTestCommandShell();
cs.setProperty(CommandShell.INTERPRETER_PROPERTY_NAME, "default");
final String[] propertyCompletions = getExpectedPropertyNameCompletions();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-07-23 15:26:03
|
Revision: 5619
http://jnode.svn.sourceforge.net/jnode/?rev=5619&view=rev
Author: crawley
Date: 2009-07-23 15:26:00 +0000 (Thu, 23 Jul 2009)
Log Message:
-----------
Bug fix: the value part of an assignment needs to be dequoted after
expansions have been performed.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-22 14:42:31 UTC (rev 5618)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-23 15:26:00 UTC (rev 5619)
@@ -966,7 +966,7 @@
}
- private String variable(String parameter) throws ShellSyntaxException {
+ String variable(String parameter) throws ShellSyntaxException {
if (BjorneToken.isName(parameter)) {
VariableSlot var = variables.get(parameter);
return (var != null) ? var.getValue() : null;
@@ -1124,7 +1124,7 @@
}
String name = assignment.substring(0, pos);
String value = dollarBacktickExpand(assignment.substring(pos + 1)).toString();
- this.setVariable(name, value);
+ this.setVariable(name, dequote(value).toString());
}
}
}
@@ -1363,14 +1363,4 @@
return variables.keySet();
}
- public String getVariable(String name) {
- VariableSlot slot = variables.get(name);
- if (slot == null) {
- return "";
- } else if (slot.getValue() == null) {
- return "";
- } else {
- return slot.getValue();
- }
- }
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-07-22 14:42:31 UTC (rev 5618)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-07-23 15:26:00 UTC (rev 5619)
@@ -271,8 +271,12 @@
@Override
public String getPrompt(CommandShell shell, boolean continuation) {
- String res = context.getVariable(continuation ? "PS2" : "PS1");
- return (res == null) ? "$ " : expandPrompt(res);
+ try {
+ String res = context.variable(continuation ? "PS2" : "PS1");
+ return (res == null) ? "$ " : expandPrompt(res);
+ } catch (ShellSyntaxException ex) {
+ return "$ ";
+ }
}
private String expandPrompt(String prompt) {
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-07-22 14:42:31 UTC (rev 5618)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-07-23 15:26:00 UTC (rev 5619)
@@ -54,6 +54,22 @@
1
</output>
</testSpec>
+ <testSpec title="quote handling" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+echo ${PS1}+
+PS1="] "
+echo ${PS1}+
+PS1='] '
+echo ${PS1}+
+PS1=]\
+echo ${PS1}+
+</script>
+ <output>$ +
+] +
+] +
+] +
+</output>
+ </testSpec>
<testSpec title="``" command="test" runMode="AS_SCRIPT" rc="0">
<script>#!bjorne
A=1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-08-01 16:04:18
|
Revision: 5626
http://jnode.svn.sourceforge.net/jnode/?rev=5626&view=rev
Author: crawley
Date: 2009-08-01 16:04:05 +0000 (Sat, 01 Aug 2009)
Log Message:
-----------
Implemented the bjorne 'read' builtin.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml
Added Paths:
-----------
trunk/shell/src/shell/org/jnode/shell/bjorne/ReadBuiltin.java
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-30 14:06:07 UTC (rev 5625)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-01 16:04:05 UTC (rev 5626)
@@ -156,6 +156,7 @@
setVariable("PS1", "$ ");
setVariable("PS2", "> ");
setVariable("PS4", "+ ");
+ setVariable("IFS", " \t\n");
}
/**
@@ -568,7 +569,7 @@
* @param wordTokens the destination for the tokens.
* @throws ShellException
*/
- private void splitAndAppend(BjorneToken token, List<BjorneToken> wordTokens)
+ void splitAndAppend(BjorneToken token, List<BjorneToken> wordTokens)
throws ShellException {
String text = token.getText();
StringBuffer sb = null;
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-07-30 14:06:07 UTC (rev 5625)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-08-01 16:04:05 UTC (rev 5626)
@@ -137,6 +137,7 @@
BUILTINS.put("continue", ContinueBuiltin.FACTORY);
BUILTINS.put("exit", ExitBuiltin.FACTORY);
BUILTINS.put("export", ExportBuiltin.FACTORY);
+ BUILTINS.put("read", ReadBuiltin.FACTORY);
BUILTINS.put("readonly", ReadonlyBuiltin.FACTORY);
BUILTINS.put("return", ReturnBuiltin.FACTORY);
BUILTINS.put("set", SetBuiltin.FACTORY);
@@ -153,6 +154,8 @@
private BjorneContext context;
private BjorneParser parser;
+
+ private Reader reader;
public BjorneInterpreter() {
this.context = new BjorneContext(this);
@@ -210,13 +213,15 @@
myContext.setIO(1, new CommandOutput(capture), true);
}
BjorneTokenizer tokens = new BjorneTokenizer(reader);
- // (Save the current parser value in the case where we are called
+ // (Save the current parser and reader objects in the case where we are called
// recursively ... to interpret a back-tick command.)
- BjorneParser saved = parser;
+ BjorneParser savedParser = this.parser;
+ Reader savedReader = this.reader;
+ this.reader = reader;
parser = new BjorneParser(tokens);
try {
do {
- CommandNode tree = parser.parse();
+ CommandNode tree = this.parser.parse();
if (tree == null) {
break;
}
@@ -227,7 +232,8 @@
} while (script);
return myContext.getLastReturnCode();
} finally {
- parser = saved;
+ this.parser = savedParser;
+ this.reader = savedReader;
}
}
@@ -288,6 +294,10 @@
public boolean supportsMultiline() {
return true;
}
+
+ Reader getReader() {
+ return this.reader;
+ }
private void bindShell(CommandShell shell) {
if (this.shell != shell) {
Added: trunk/shell/src/shell/org/jnode/shell/bjorne/ReadBuiltin.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/ReadBuiltin.java (rev 0)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/ReadBuiltin.java 2009-08-01 16:04:05 UTC (rev 5626)
@@ -0,0 +1,212 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2003-2009 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.jnode.shell.bjorne;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jnode.shell.ShellSyntaxException;
+import org.jnode.shell.syntax.Argument;
+import org.jnode.shell.syntax.ArgumentSyntax;
+import org.jnode.shell.syntax.FlagArgument;
+import org.jnode.shell.syntax.OptionSyntax;
+import org.jnode.shell.syntax.OptionalSyntax;
+import org.jnode.shell.syntax.RepeatSyntax;
+import org.jnode.shell.syntax.SequenceSyntax;
+import org.jnode.shell.syntax.SyntaxBundle;
+
+/**
+ * This class implements the 'read' built-in.
+ *
+ * @author cr...@jn...
+ */
+final class ReadBuiltin extends BjorneBuiltin {
+ private static final SyntaxBundle SYNTAX =
+ new SyntaxBundle("read", new SequenceSyntax(
+ new OptionalSyntax(new OptionSyntax("noEscape", 'r')),
+ new RepeatSyntax(new ArgumentSyntax("varName"), 0, Integer.MAX_VALUE)));
+
+ static final Factory FACTORY = new Factory() {
+ public BjorneBuiltinCommandInfo buildCommandInfo(BjorneContext context) {
+ return new BjorneBuiltinCommandInfo("read", SYNTAX, new ReadBuiltin(context), context);
+ }
+ };
+
+
+ private final VariableNameArgument varNameArg;
+ private final FlagArgument noEscapeArg = new FlagArgument(
+ "noEscape", Argument.OPTIONAL, "if set, '\' does not escape a newline");
+
+ private final BjorneContext context;
+ Pattern ifsSplittingPattern;
+ Pattern ifsTrimmingPattern;
+
+ ReadBuiltin(BjorneContext context) {
+ super("Read a line of input and repopulate the shell 'args'");
+ this.context = context;
+ varNameArg = new VariableNameArgument(
+ "varName", context, Argument.OPTIONAL | Argument.MULTIPLE, "shell variables to be set");
+ registerArguments(noEscapeArg, varNameArg);
+ }
+
+ public void execute() throws Exception {
+ boolean escapeCheck = !noEscapeArg.isSet();
+ String line = readLine(getInput().getReader(), escapeCheck);
+ String[] varNames = varNameArg.getValues();
+ if (varNames.length > 0) {
+ String[] fields = extractFields(line, varNames.length);
+ for (int i = 0; i < varNames.length; i++) {
+ String value = (i >= fields.length || fields[i] == null) ? "" : fields[i];
+ context.getParent().setVariable(varNames[i], value);
+ }
+ }
+ }
+
+ private String[] extractFields(String line, int nosVars) throws ShellSyntaxException {
+ String ifs = context.variable("IFS");
+ if (ifs == null) {
+ ifs = " \t\n";
+ } else if (ifs.length() == 0) {
+ return new String[]{line};
+ }
+
+ String[] fields = new String[nosVars];
+ createIfsPatterns(ifs);
+ String content;
+ if (ifsTrimmingPattern != null) {
+ Matcher trimMatcher = ifsTrimmingPattern.matcher(line);
+ trimMatcher.matches();
+ content = trimMatcher.group(1);
+ } else {
+ content = line;
+ }
+ if (line.length() == 0) {
+ return new String[0];
+ }
+ Matcher fieldMatcher = null;
+ for (int i = 0; i < fields.length - 1; i++) {
+ if (fieldMatcher == null) {
+ fieldMatcher = ifsSplittingPattern.matcher(content);
+ } else {
+ fieldMatcher.reset(content);
+ }
+ if (fieldMatcher.matches()) {
+ fields[i] = fieldMatcher.group(1);
+ content = fieldMatcher.group(2);
+ } else {
+ fields[i] = content;
+ content = null;
+ break;
+ }
+ }
+ if (content != null) {
+ fields[fields.length - 1] = content;
+ }
+ return fields;
+ }
+
+ private void createIfsPatterns(String ifs) {
+ if (ifs.equals(" ") || ifs.equals("\t") || ifs.equals("\n")) {
+ ifsTrimmingPattern = Pattern.compile("[ \\t\\n]*(.*[^ \\t\\n])[ \\t\\n]*");
+ ifsSplittingPattern = Pattern.compile("([^ \\t\\n]+)[ \\t\\n]+([^ \\t\\n].*)");
+ } else {
+ // First separate the IFS into whitespace and non-whitespace characters,
+ // adding '\' escapes for any that characters that need to be escaped.
+ StringBuilder sb1 = new StringBuilder(4);
+ StringBuilder sb2 = new StringBuilder(4);
+ for (char ch : ifs.toCharArray()) {
+ switch (ch) {
+ case ' ':
+ sb1.append(' ');
+ break;
+ case '\t':
+ sb1.append("\\t");
+ break;
+ case '\n':
+ sb1.append("\\n");
+ break;
+ case '.':
+ case '?':
+ case '*':
+ case '+':
+ case '[':
+ case ']':
+ case '(':
+ case ')':
+ case '|':
+ case '{':
+ case '}':
+ case '\\':
+ case '^':
+ case '$':
+ case '-':
+ sb2.append('\\').append(ch);
+ break;
+ default:
+ sb2.append("\\\n");
+ break;
+ }
+ }
+ String ifsWhitespace = sb1.toString();
+ String ifsNonWhitespace = sb2.toString();
+ // If we have any IFS whitespace, create the pattern to trim it.
+ if (ifsWhitespace.length() == 0) {
+ ifsTrimmingPattern = null;
+ } else {
+ ifsTrimmingPattern = Pattern.compile(
+ "[" + ifsWhitespace + "]*(.*[^" + ifsWhitespace + "])[" + ifsWhitespace + "]*");
+ }
+ // Create the pattern to split a (possibly empty) field
+ if (ifsWhitespace.length() > 0 && ifsNonWhitespace.length() > 0) {
+ ifsSplittingPattern = Pattern.compile(
+ "([^" + ifsWhitespace + ifsNonWhitespace + "]*)[" + ifsWhitespace + "]*[" +
+ ifsNonWhitespace + "][" + ifsWhitespace + "]*(|[^" + ifsWhitespace + "].*)");
+ } else if (ifsWhitespace.length() > 0) {
+ ifsSplittingPattern = Pattern.compile(
+ "([^" + ifsWhitespace +"]*)[" + ifsWhitespace + "]+(|[^" + ifsWhitespace + "].*)");
+ } else {
+ ifsSplittingPattern = Pattern.compile(
+ "([^" + ifsNonWhitespace + "]*)[" + ifsNonWhitespace + "](.*)");
+ }
+ }
+ }
+
+ private String readLine(Reader reader, boolean escapeCheck) throws IOException {
+ StringBuilder sb = new StringBuilder(40);
+ int ch;
+ while ((ch = reader.read()) != -1 && ch != '\n') {
+ if (ch == '\\' && escapeCheck) {
+ ch = reader.read();
+ if (ch == -1) {
+ sb.append('\\');
+ break;
+ } else if (ch != '\n') {
+ sb.append('\\').append((char) ch);
+ }
+ } else {
+ sb.append((char) ch);
+ }
+ }
+ return sb.toString();
+ }
+}
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml 2009-07-30 14:06:07 UTC (rev 5625)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml 2009-08-01 16:04:05 UTC (rev 5626)
@@ -128,4 +128,27 @@
A --
</output>
</testSpec>
+ <testSpec title="read" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ read <<EOF
+1 2 3
+EOF
+ read A B C <<EOF
+1 2 3
+EOF
+ echo +$A+ +$B+ +$C+
+ read A B C D <<EOF
+ 1 2 3
+EOF
+ echo +$A+ +$B+ +$C+ +$D+
+ read A B <<EOF
+ 1 2 3
+EOF
+ echo +$A+ +$B+
+ </script>
+ <output>+1+ +2+ +3+
++1+ +2+ +3+ ++
++1+ +2 3+
+</output>
+ </testSpec>
</testSet>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-08-09 05:23:27
|
Revision: 5632
http://jnode.svn.sourceforge.net/jnode/?rev=5632&view=rev
Author: crawley
Date: 2009-08-09 05:23:19 +0000 (Sun, 09 Aug 2009)
Log Message:
-----------
Overhauled Bjorne's expansion of `...`, $XXX, ${XXX...} and so on to make nested expansions work; e.g. ${A:-${B}}
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CharIterator.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-07 08:37:53 UTC (rev 5631)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-09 05:23:19 UTC (rev 5632)
@@ -72,10 +72,8 @@
* @author cr...@jn...
*/
public class BjorneContext {
-
- private static final int NONE = 0;
- private static final int PREHASH = 1;
+ private static final int NONE = 1;
private static final int HASH = 2;
@@ -409,7 +407,7 @@
for (BjorneToken token : tokens) {
dollarBacktickSplit(token, wordTokens);
}
- wordTokens = doFileExpansions(wordTokens);
+ wordTokens = fileExpand(wordTokens);
wordTokens = dequote(wordTokens);
return wordTokens;
}
@@ -426,7 +424,7 @@
for (BjorneToken token : tokens) {
dollarBacktickSplit(token, wordTokens);
}
- wordTokens = doFileExpansions(wordTokens);
+ wordTokens = fileExpand(wordTokens);
wordTokens = dequote(wordTokens);
return wordTokens;
}
@@ -504,7 +502,7 @@
}
}
- private List<BjorneToken> doFileExpansions(List<BjorneToken> wordTokens) {
+ private List<BjorneToken> fileExpand(List<BjorneToken> wordTokens) {
if (globbing || tildeExpansion) {
List<BjorneToken> globbedWordTokens = new LinkedList<BjorneToken>();
for (BjorneToken wordToken : wordTokens) {
@@ -512,7 +510,7 @@
wordToken = tildeExpand(wordToken);
}
if (globbing) {
- globAndAppend(wordToken, globbedWordTokens);
+ globAppend(wordToken, globbedWordTokens);
} else {
globbedWordTokens.add(wordToken);
}
@@ -541,7 +539,7 @@
}
}
- private void globAndAppend(BjorneToken wordToken, List<BjorneToken> globbedWordTokens) {
+ private void globAppend(BjorneToken wordToken, List<BjorneToken> globbedWordTokens) {
// Try to deal with the 'not-a-pattern' case quickly and cheaply.
String word = wordToken.getText();
if (!PathnamePattern.isPattern(word)) {
@@ -642,37 +640,26 @@
* @throws ShellException
*/
public CharSequence dollarBacktickExpand(CharSequence text) throws ShellException {
- CharIterator ci = new CharIterator(text);
- StringBuilder sb = new StringBuilder(text.length());
- char quote = 0;
- int backtickStart = -1;
- int ch = ci.nextCh();
- while (ch != -1) {
+ return dollarBacktickExpand(new CharIterator(text), -1);
+ }
+
+ private CharSequence dollarBacktickExpand(CharIterator ci, int terminator) throws ShellException {
+ StringBuilder sb = new StringBuilder(ci.nosRemaining());
+ int ch = ci.peekCh();
+ while (ch != -1 && ch != terminator) {
+ ci.nextCh();
switch (ch) {
case '"':
+ sb.append(doubleQuoteExpand(ci));
+ break;
case '\'':
- if (quote == 0) {
- quote = (char) ch;
- } else if (quote == ch) {
- quote = 0;
- }
- sb.append((char) ch);
+ sb.append(singleQuoteExpand(ci));
break;
case '`':
- if (backtickStart == -1) {
- backtickStart = sb.length();
- } else {
- StringBuffer tmp = runBacktickCommand(sb.substring(backtickStart));
- sb.replace(backtickStart, sb.length(), tmp.toString());
- backtickStart = -1;
- }
+ sb.append(backQuoteExpand(ci));
break;
- case ' ':
- case '\t':
- sb.append(' ');
- while ((ch = ci.peekCh()) == ' ' || ch == '\t') {
- ci.nextCh();
- }
+ case '$':
+ sb.append(dollarExpand(ci, (char) -1));
break;
case '\\':
sb.append((char) ch);
@@ -680,206 +667,205 @@
sb.append((char) ch);
}
break;
- case '$':
- if (quote == '\'') {
- sb.append('$');
- } else {
- String tmp = dollarExpansion(ci, quote);
- sb.append(tmp == null ? "" : tmp);
- }
- break;
-
default:
sb.append((char) ch);
break;
}
- ch = ci.nextCh();
+ ch = ci.peekCh();
}
- if (backtickStart != -1) {
- throw new ShellFailureException("unmatched '`'");
- }
return sb;
}
- private String dollarExpansion(CharIterator ci, char quote) throws ShellException {
+ private StringBuilder doubleQuoteExpand(CharIterator ci) throws ShellException {
+ StringBuilder sb = new StringBuilder(ci.nosRemaining());
+ sb.append('"');
int ch = ci.nextCh();
- switch (ch) {
- case -1:
- return "$";
- case '{':
- return dollarBraceExpansion(ci);
- case '(':
- return dollarParenExpansion(ci);
- case '$':
- case '#':
- case '@':
- case '*':
- case '?':
- case '!':
- case '-':
- return specialVariable(ch, quote == '"');
- default:
- StringBuilder sb = new StringBuilder().append((char) ch);
- ch = ci.peekCh();
- while ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_') {
- sb.append((char) ch);
- ci.nextCh();
- ch = ci.peekCh();
- }
- return variable(sb.toString());
- }
- }
-
- private String dollarBraceExpansion(CharIterator ci) throws ShellException {
- // Scan to the '}' that matches the '${'
- StringBuilder sb = new StringBuilder();
- int braceLevel = 1;
- int ch = ci.nextCh();
- int quote = 0;
- LOOP:
while (ch != -1) {
switch (ch) {
- case '}':
- if (quote == 0) {
- braceLevel--;
- if (braceLevel == 0) {
- break LOOP;
- }
- }
+ case '\'':
+ sb.append(singleQuoteExpand(ci));
break;
- case '{':
- if (quote == 0) {
- braceLevel++;
- }
+ case '"':
+ sb.append('"');
+ return sb;
+ case '$':
+ sb.append(dollarExpand(ci, '"'));
break;
case '\\':
sb.append((char) ch);
- ch = ci.nextCh();
- break;
- case '"':
- case '\'':
- if (quote == 0) {
- quote = ch;
- } else if (quote == ch) {
- quote = 0;
+ if ((ch = ci.nextCh()) != -1) {
+ sb.append((char) ch);
}
break;
default:
- // Nothing to do
+ sb.append((char) ch);
break;
}
- if (ch != -1) {
- sb.append((char) ch);
- }
ch = ci.nextCh();
}
-
- if (braceLevel > 0) {
- throw new ShellSyntaxException("unmatched '{'");
- }
+ throw new ShellSyntaxException("Unmatched \"'\" (double quote)");
+ }
- // Deal with case where the braces are empty ...
- if (sb.length() == 0) {
- return "";
- }
-
- // Extract the parameter name, noting a leading '#' operator
- int operator = NONE;
- int i;
- LOOP:
- for (i = 0; i < sb.length(); i++) {
- char ch2 = sb.charAt(i);
- switch (ch2) {
- case '#':
- if (i == 0) {
- operator = PREHASH;
- } else {
- break LOOP;
+ private Object singleQuoteExpand(CharIterator ci) throws ShellSyntaxException {
+ StringBuilder sb = new StringBuilder(ci.nosRemaining());
+ sb.append('\'');
+ int ch = ci.nextCh();
+ while (ch != -1) {
+ switch (ch) {
+ case '\'':
+ sb.append('\'');
+ return sb;
+ case '\\':
+ sb.append((char) ch);
+ if ((ch = ci.nextCh()) != -1) {
+ sb.append((char) ch);
}
break;
- case '%':
- case ':':
- case '=':
- case '?':
- case '+':
- case '-':
- break LOOP;
default:
- // Include this in the parameter name for now.
+ sb.append((char) ch);
break;
}
+ ch = ci.nextCh();
}
+ throw new ShellSyntaxException("Unmatched '\"' (single quote)");
+ }
- String parameter = sb.substring(operator == NONE ? 0 : 1, i);
- String word = null;
-
- if (i < sb.length()) {
- // Work out what the operator is ...
- char opch = sb.charAt(i);
- char opch2 = (i + 1 < sb.length()) ? sb.charAt(i + 1) : (char) 0;
- switch (opch) {
- case '#':
- operator = (opch2 == '#') ? DHASH : HASH;
+ private CharSequence backQuoteExpand(CharIterator ci) throws ShellException {
+ StringBuilder sb = new StringBuilder(ci.nosRemaining());
+ int ch = ci.nextCh();
+ while (ch != -1) {
+ switch (ch) {
+ case '"':
+ sb.append(doubleQuoteExpand(ci));
break;
- case '%':
- operator = (opch2 == '%') ? DPERCENT : PERCENT;
+ case '\'':
+ sb.append(singleQuoteExpand(ci));
break;
- case ':':
- switch (opch2) {
- case '=':
- operator = COLONEQUALS;
- break;
- case '+':
- operator = COLONPLUS;
- break;
- case '?':
- operator = COLONQUERY;
- break;
- case '-':
- operator = COLONHYPHEN;
- break;
- default:
- throw new ShellSyntaxException("bad substitution");
+ case '`':
+ return runBacktickCommand(sb.toString());
+ case '$':
+ sb.append(dollarExpand(ci, '`'));
+ break;
+ case '\\':
+ sb.append((char) ch);
+ if ((ch = ci.nextCh()) != -1) {
+ sb.append((char) ch);
}
break;
- case '=':
- operator = EQUALS;
- break;
- case '?':
- operator = QUERY;
- break;
- case '+':
- operator = PLUS;
- break;
- case '-':
- operator = HYPHEN;
- break;
default:
- throw new ShellFailureException("bad state");
- }
- // Adjust for two-character operators
- switch (operator) {
- case EQUALS:
- case QUERY:
- case PLUS:
- case HYPHEN:
- case HASH:
- case PERCENT:
- i++;
+ sb.append((char) ch);
break;
- default:
- i += 2;
- break;
}
- // Extract the word
- word = sb.substring(i);
+ ch = ci.nextCh();
}
- String value = dollarExpansion(new CharIterator(parameter), '\000');
+ throw new ShellSyntaxException("Unmatched \"`\" (back quote)");
+ }
+
+ private CharSequence dollarExpand(CharIterator ci, char quote) throws ShellException {
+ int ch = ci.peekCh();
+ switch (ch) {
+ case -1:
+ return "$";
+ case '{':
+ ci.nextCh();
+ return dollarBraceExpand(ci);
+ case '(':
+ ci.nextCh();
+ return dollarParenExpand(ci);
+ case '$':
+ case '#':
+ case '@':
+ case '*':
+ case '?':
+ case '!':
+ case '-':
+ ci.nextCh();
+ return specialVariable(ch, quote == '"');
+ default:
+ String parameter = parseParameter(ci);
+ String value = (parameter.length() == 0) ? "$" : variable(parameter);
+ return value == null ? "" : value;
+ }
+ }
+
+ private CharSequence dollarBraceExpand(CharIterator ci) throws ShellException {
+ int ch = ci.peekCh();
+ if (ch == '#') {
+ ci.nextCh();
+ String parameter = parseParameter(ci);
+ if (ci.nextCh() != '}') {
+ throw new ShellSyntaxException("Unmatched \"{\"");
+ }
+ String value = variable(parameter);
+ return (value != null) ? Integer.toString(value.length()) : "0";
+ }
+ String parameter = parseParameter(ci);
+ ch = ci.nextCh();
+ int operator = NONE;
+ switch (ch) {
+ case -1:
+ throw new ShellSyntaxException("Unmatched \"{\"");
+ case '}':
+ break;
+ case '#':
+ if (ci.peekCh() == '#') {
+ ci.nextCh();
+ operator = DHASH;
+ } else {
+ operator = HASH;
+ }
+ break;
+ case '%':
+ if (ci.peekCh() == '%') {
+ ci.nextCh();
+ operator = DPERCENT;
+ } else {
+ operator = PERCENT;
+ }
+ break;
+ case ':':
+ switch (ci.peekCh()) {
+ case '=':
+ operator = COLONEQUALS;
+ break;
+ case '+':
+ operator = COLONPLUS;
+ break;
+ case '?':
+ operator = COLONQUERY;
+ break;
+ case '-':
+ operator = COLONHYPHEN;
+ break;
+ default:
+ throw new ShellSyntaxException("bad substitution operator");
+ }
+ ci.nextCh();
+ break;
+ case '=':
+ operator = EQUALS;
+ break;
+ case '?':
+ operator = QUERY;
+ break;
+ case '+':
+ operator = PLUS;
+ break;
+ case '-':
+ operator = HYPHEN;
+ break;
+ default:
+ throw new ShellSyntaxException("unrecognized substitution operator (\"" + (char) ch + "\")");
+ }
+ String value = variable(parameter);
+ if (operator == NONE) {
+ return (value != null) ? value : "";
+ }
+ String word = dollarBacktickExpand(ci, '}').toString();
+ if (ci.nextCh() != '}') {
+ throw new ShellSyntaxException("Unmatched \"{\"");
+ }
switch (operator) {
- case NONE:
- return (value != null) ? value : "";
- case PREHASH:
- return (value != null) ? Integer.toString(value.length()) : "0";
case HYPHEN:
return (value == null) ? word : value;
case COLONHYPHEN:
@@ -919,18 +905,29 @@
return value;
}
case HASH:
- return patternEdit(value, word, false, false);
+ return patternEdit(value.toString(), word, false, false);
case DHASH:
- return patternEdit(value, word, false, true);
+ return patternEdit(value.toString(), word, false, true);
case PERCENT:
- return patternEdit(value, word, true, false);
+ return patternEdit(value.toString(), word, true, false);
case DPERCENT:
- return patternEdit(value, word, true, true);
+ return patternEdit(value.toString(), word, true, true);
default:
- throw new ShellFailureException("not implemented");
+ throw new ShellFailureException("unimplemented substitution operator (" + operator + ")");
}
}
+ private String parseParameter(CharIterator ci) throws ShellSyntaxException {
+ StringBuilder sb = new StringBuilder();
+ int ch = ci.peekCh();
+ while (Character.isLetterOrDigit((char) ch) || ch == '_') {
+ sb.append((char) ch);
+ ci.nextCh();
+ ch = ci.peekCh();
+ }
+ return sb.toString();
+ }
+
private String patternEdit(String value, String pattern, boolean suffix, boolean eager) {
if (value == null || value.length() == 0) {
return "";
@@ -1030,11 +1027,81 @@
public boolean isSet(String name) {
return variables.get(name) != null;
}
-
- private String dollarParenExpansion(CharIterator ci) {
- throw new ShellFailureException("not implemented");
+
+ private String dollarParenExpand(CharIterator ci) throws ShellException {
+ throw new ShellSyntaxException("$( and $(( not implemented yet");
}
+// private String dollarParenExpand(CharIterator ci) throws ShellException {
+// StringBuilder sb = extractToMatchingParen(ci);
+// if (sb.length() > 0 && sb.charAt(sb.length()) == ')') {
+// throw new ShellSyntaxException(
+// "There should be a space between the two ')'s in '$(...))'");
+// }
+// return runBacktickCommand(sb.toString()).toString();
+// }
+//
+// private StringBuilder extractToMatchingParen(CharIterator ci) throws ShellSyntaxException {
+// StringBuilder sb = new StringBuilder(40);
+// Deque<Character> stack = new ArrayDeque<Character>();
+// int ch;
+// boolean more = true;
+// do {
+// ch = ci.nextCh();
+// switch (ch) {
+// case -1:
+// if (!stack.isEmpty()) {
+// throw new ShellSyntaxException("unmatched '('");
+// }
+// more = false;
+// break;
+// case ')':
+// if (stack.isEmpty()) {
+// more = false;
+// } else {
+// sb.append(')');
+// if (stack.peekFirst() == '(') {
+// stack.removeFirst();
+// }
+// }
+// break;
+// case '(':
+// if (stack.isEmpty() || stack.peekFirst() == '(') {
+// stack.addFirst('(');
+// }
+// sb.append('(');
+// break;
+// case '"':
+// case '\'':
+// case '`':
+// sb.append((char) ch);
+// if (stack.isEmpty()) {
+// stack.addFirst((char) ch);
+// } else {
+// char top = stack.peekFirst();
+// if (top != '"' && top != '\'' && top != '`') {
+// stack.addFirst('"');
+// } else if (top == ch) {
+// stack.removeFirst();
+// }
+// }
+// break;
+// case '\\':
+// sb.append('\\');
+// ch = ci.nextCh();
+// if (ch == -1) {
+// more = false;
+// } else {
+// sb.append((char) ch);
+// }
+// break;
+// default:
+// sb.append((char) ch);
+// }
+// } while (more);
+// return sb;
+// }
+
int execute(CommandLine command, CommandIO[] streams, boolean isBuiltin) throws ShellException {
if (isEchoExpansions()) {
StringBuilder sb = new StringBuilder();
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CharIterator.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/CharIterator.java 2009-08-07 08:37:53 UTC (rev 5631)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/CharIterator.java 2009-08-09 05:23:19 UTC (rev 5632)
@@ -47,4 +47,8 @@
public int lastCh() {
return (pos > start) ? str.charAt(pos - 1) : -1;
}
+
+ public int nosRemaining() {
+ return limit - pos;
+ }
}
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java 2009-08-07 08:37:53 UTC (rev 5631)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java 2009-08-09 05:23:19 UTC (rev 5632)
@@ -189,7 +189,42 @@
expansion = context.buildCommandLine(new BjorneToken("~"));
checkExpansion(expansion, new String[] {"~"});
}
+
+ public void testExpand17() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext(null, null);
+ context.setVariable("A", "A");
+ List<BjorneToken> expansion = context.expandAndSplit(
+ new BjorneToken("${A}"));
+ checkExpansion(expansion, new String[] {"A"});
+ }
+ public void testExpand18() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext(null, null);
+ context.setVariable("A", "A");
+ context.setVariable("B", "");
+ List<BjorneToken> expansion = context.expandAndSplit(
+ new BjorneToken("${#A} ${#B} ${#C}"));
+ checkExpansion(expansion, new String[] {"1", "0", "0"});
+ }
+
+ public void testExpand19() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext(null, null);
+ context.setVariable("A", "A");
+ context.setVariable("B", "");
+ List<BjorneToken> expansion = context.expandAndSplit(
+ new BjorneToken("${A:-X} ${B:-Y} ${C:-Z}"));
+ checkExpansion(expansion, new String[] {"A", "Y", "Z"});
+ }
+
+ public void testExpand20() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext(null, null);
+ context.setVariable("A", "");
+ context.setVariable("B", "B");
+ List<BjorneToken> expansion = context.expandAndSplit(
+ new BjorneToken("${A:-$B} ${A:-${B}} ${A:-${A:-$B}} ${A:-'${B}'}"));
+ checkExpansion(expansion, new String[] {"B", "B", "B", "${B}"});
+ }
+
private void checkExpansion(List<BjorneToken> expansion, String[] expected) {
int i;
Iterator<BjorneToken> it = expansion.iterator();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-08-09 14:52:24
|
Revision: 5634
http://jnode.svn.sourceforge.net/jnode/?rev=5634&view=rev
Author: crawley
Date: 2009-08-09 14:52:17 +0000 (Sun, 09 Aug 2009)
Log Message:
-----------
Implemented command substitution using the $(...) syntax.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-09 07:20:10 UTC (rev 5633)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-09 14:52:17 UTC (rev 5634)
@@ -613,7 +613,7 @@
}
}
- private StringBuffer runBacktickCommand(String commandLine) throws ShellException {
+ protected StringBuffer runBacktickCommand(String commandLine) throws ShellException {
StringWriter capture = new StringWriter();
interpreter.interpret(interpreter.getShell(), new StringReader(commandLine), false, capture, false);
StringBuffer output = capture.getBuffer();
@@ -1027,11 +1027,26 @@
public boolean isSet(String name) {
return variables.get(name) != null;
}
-
- private String dollarParenExpand(CharIterator ci) throws ShellException {
- throw new ShellSyntaxException("$( and $(( not implemented yet");
+
+ private CharSequence dollarParenExpand(CharIterator ci) throws ShellException {
+ if (ci.peekCh() == '(') {
+ ci.nextCh();
+ return dollarParenParenExpand(ci);
+ }
+ else {
+ String commandLine = dollarBacktickExpand(ci, ')').toString();
+ if (ci.nextCh() != ')') {
+ throw new ShellSyntaxException("Unmatched \"(\" (left parenthesis)");
+ }
+ return runBacktickCommand(commandLine);
+ }
}
+ private CharSequence dollarParenParenExpand(CharIterator ci) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
// private String dollarParenExpand(CharIterator ci) throws ShellException {
// StringBuilder sb = extractToMatchingParen(ci);
// if (sb.length() > 0 && sb.charAt(sb.length()) == ')') {
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java 2009-08-09 07:20:10 UTC (rev 5633)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java 2009-08-09 14:52:17 UTC (rev 5634)
@@ -31,7 +31,6 @@
import org.jnode.shell.PathnamePattern;
import org.jnode.shell.ShellException;
import org.jnode.shell.bjorne.BjorneContext;
-import org.jnode.shell.bjorne.BjorneInterpreter;
import org.jnode.shell.bjorne.BjorneToken;
import org.jnode.shell.io.CommandIOHolder;
@@ -45,77 +44,94 @@
// This class simply allows us to call the setVariable method directly
private static class TestBjorneContext extends BjorneContext {
- TestBjorneContext(BjorneInterpreter interpreter, CommandIOHolder[] holders) {
- super(interpreter, holders);
+ TestBjorneContext(CommandIOHolder[] holders) {
+ super(null, holders);
}
+ TestBjorneContext() {
+ super(null, null);
+ }
+
+ /**
+ * Expose method for testing
+ */
@Override
protected void setVariable(String name, String value) {
super.setVariable(name, value);
}
+
+ /**
+ * For testing, 'execute' a command by converting to lowercase with '-' guards.
+ */
+ @Override
+ protected StringBuffer runBacktickCommand(String commandLine) throws ShellException {
+ return new StringBuffer("-" + commandLine.toLowerCase() + "-");
+ }
}
+
+
public void testContext() {
new BjorneContext(null, null);
}
public void testExpand1() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ BjorneContext context = new TestBjorneContext();
List<BjorneToken> expansion = context.expandAndSplit();
checkExpansion(expansion, new String[] {});
}
public void testExpand3() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ BjorneContext context = new TestBjorneContext();
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("hi"));
checkExpansion(expansion, new String[] {"hi"});
}
public void testExpand4() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ BjorneContext context = new TestBjorneContext();
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("hi there"));
checkExpansion(expansion, new String[] {"hi", "there"});
}
public void testExpand5() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ BjorneContext context = new TestBjorneContext();
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("'hi there '"));
checkExpansion(expansion, new String[] {"hi there "});
}
public void testExpand6() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ BjorneContext context = new TestBjorneContext();
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("\"hi there \" "));
checkExpansion(expansion, new String[] {"hi there "});
}
public void testExpand7() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ BjorneContext context = new TestBjorneContext();
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("hi\\ there"));
checkExpansion(expansion, new String[] {"hi there"});
}
public void testExpand8() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ BjorneContext context = new TestBjorneContext();
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("\\\"hi\\ there\\\""));
checkExpansion(expansion, new String[] {"\"hi there\""});
}
public void testExpand9() throws ShellException {
- BjorneContext context = new BjorneContext(null, null);
+ BjorneContext context = new TestBjorneContext();
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("$?"));
checkExpansion(expansion, new String[] {"0"});
}
public void testExpand10() throws ShellException {
- TestBjorneContext context = new TestBjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext();
context.setVariable("A", "A");
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("$A"));
@@ -123,7 +139,7 @@
}
public void testExpand11() throws ShellException {
- TestBjorneContext context = new TestBjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext();
context.setVariable("A", "A");
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("\\$A"));
@@ -131,7 +147,7 @@
}
public void testExpand12() throws ShellException {
- TestBjorneContext context = new TestBjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext();
context.setVariable("A", "A");
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("\"$A\""));
@@ -139,7 +155,7 @@
}
public void testExpand13() throws ShellException {
- TestBjorneContext context = new TestBjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext();
context.setVariable("A", "A");
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("'$A'"));
@@ -147,7 +163,7 @@
}
public void testExpand14() throws ShellException {
- TestBjorneContext parentContext = new TestBjorneContext(null, new CommandIOHolder[0]);
+ TestBjorneContext parentContext = new TestBjorneContext(new CommandIOHolder[0]);
parentContext.setVariable("A", "A");
BjorneContext context = new BjorneContext(parentContext);
List<BjorneToken> expansion = context.expandAndSplit(
@@ -157,7 +173,7 @@
public void testExpand15() throws Exception {
PathnamePattern.clearCache();
- BjorneContext context = new BjorneContext(null, null);
+ BjorneContext context = new TestBjorneContext();
assertEquals(true, context.isGlobbing());
assertEquals(true, context.isTildeExpansion());
if (new File("../README.txt").exists()) {
@@ -180,7 +196,7 @@
}
public void testExpand16() throws Exception {
- BjorneContext context = new BjorneContext(null, null);
+ BjorneContext context = new TestBjorneContext();
assertEquals(true, context.isGlobbing());
assertEquals(true, context.isTildeExpansion());
CommandLine expansion = context.buildCommandLine(new BjorneToken("~"));
@@ -191,7 +207,7 @@
}
public void testExpand17() throws ShellException {
- TestBjorneContext context = new TestBjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext();
context.setVariable("A", "A");
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("${A}"));
@@ -199,7 +215,7 @@
}
public void testExpand18() throws ShellException {
- TestBjorneContext context = new TestBjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext();
context.setVariable("A", "A");
context.setVariable("B", "");
List<BjorneToken> expansion = context.expandAndSplit(
@@ -208,7 +224,7 @@
}
public void testExpand19() throws ShellException {
- TestBjorneContext context = new TestBjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext();
context.setVariable("A", "A");
context.setVariable("B", "");
List<BjorneToken> expansion = context.expandAndSplit(
@@ -217,14 +233,28 @@
}
public void testExpand20() throws ShellException {
- TestBjorneContext context = new TestBjorneContext(null, null);
+ TestBjorneContext context = new TestBjorneContext();
context.setVariable("A", "");
context.setVariable("B", "B");
List<BjorneToken> expansion = context.expandAndSplit(
new BjorneToken("${A:-$B} ${A:-${B}} ${A:-${A:-$B}} ${A:-'${B}'}"));
checkExpansion(expansion, new String[] {"B", "B", "B", "${B}"});
}
+
+ public void testExpand21() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext();
+ List<BjorneToken> expansion = context.expandAndSplit(
+ new BjorneToken("`Hello`"));
+ checkExpansion(expansion, new String[] {"-hello-"});
+ }
+ public void testExpand22() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext();
+ List<BjorneToken> expansion = context.expandAndSplit(
+ new BjorneToken("$(Hello)"));
+ checkExpansion(expansion, new String[] {"-hello-"});
+ }
+
private void checkExpansion(List<BjorneToken> expansion, String[] expected) {
int i;
Iterator<BjorneToken> it = expansion.iterator();
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-08-09 07:20:10 UTC (rev 5633)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-08-09 14:52:17 UTC (rev 5634)
@@ -70,7 +70,7 @@
] +
</output>
</testSpec>
- <testSpec title="``" command="test" runMode="AS_SCRIPT" rc="0">
+ <testSpec title="`...`" command="test" runMode="AS_SCRIPT" rc="0">
<script>#!bjorne
A=1
echo $A
@@ -84,6 +84,20 @@
1 1
</output>
</testSpec>
+ <testSpec title="$(...)" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+A=1
+echo $A
+B="$(expr $A + 1)"
+echo $B
+C="$(echo $A $A)"
+echo $C
+</script>
+ <output>1
+2
+1 1
+</output>
+ </testSpec>
<testSpec title="if ... then ... fi" command="test" runMode="AS_SCRIPT" rc="0">
<script>#!bjorne
if true ; then echo HI ; fi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-08-20 11:24:49
|
Revision: 5656
http://jnode.svn.sourceforge.net/jnode/?rev=5656&view=rev
Author: crawley
Date: 2009-08-20 11:24:38 +0000 (Thu, 20 Aug 2009)
Log Message:
-----------
Working on support for $((expression)) ...
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
Added Paths:
-----------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneArithmeticEvaluator.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneArithmeticEvaluatorTest.java
Added: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneArithmeticEvaluator.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneArithmeticEvaluator.java (rev 0)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneArithmeticEvaluator.java 2009-08-20 11:24:38 UTC (rev 5656)
@@ -0,0 +1,324 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2003-2009 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+package org.jnode.shell.bjorne;
+
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import org.jnode.shell.ShellException;
+import org.jnode.shell.ShellFailureException;
+import org.jnode.shell.ShellSyntaxException;
+
+/**
+ * This class parses and evaluates the bjorne shell's arithmetic expression sublanguage.
+ *
+ * @author cr...@jn...
+ */
+public class BjorneArithmeticEvaluator {
+
+ private static final int NONE = 1;
+ private static final int PERCENT = 2;
+ private static final int MINUS = 3;
+ private static final int PLUS = 4;
+ private static final int STAR = 5;
+ private static final int SLASH = 6;
+ private static final int PLUSPLUS = 7;
+ private static final int MINUSMINUS = 8;
+ private static final int PLING = 9;
+ private static final int TWIDDLE = 10;
+ private static final int STARSTAR = 11;
+
+ private static final int PREFIX = 16;
+
+ private static final HashMap<Integer, Integer> precedence = new HashMap<Integer, Integer>();
+ private static final HashSet<Integer> unaryOps;
+ static {
+ precedence.put(PLUSPLUS, 1);
+ precedence.put(MINUSMINUS, 1);
+ precedence.put(PLUSPLUS + PREFIX, 2);
+ precedence.put(MINUSMINUS + PREFIX, 2);
+ precedence.put(PLUS + PREFIX, 3);
+ precedence.put(MINUS + PREFIX, 3);
+ precedence.put(PLING + PREFIX, 4);
+ precedence.put(TWIDDLE + PREFIX, 4);
+ precedence.put(STARSTAR, 5);
+ precedence.put(STAR, 6);
+ precedence.put(SLASH, 6);
+ precedence.put(PERCENT, 6);
+ precedence.put(PLUS, 7);
+ precedence.put(MINUS, 7);
+ unaryOps = new HashSet<Integer>(Arrays.asList(new Integer[]{
+ PLUS + PREFIX, PLUSPLUS, PLUSPLUS + PREFIX,
+ MINUS + PREFIX, MINUSMINUS, MINUSMINUS + PREFIX}));
+ };
+
+
+ private class Primary {
+ private final String name;
+ private final long value;
+
+ public Primary(String name, long value) {
+ super();
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public long getValue() throws ShellSyntaxException {
+ return name != null ? evalName(name) : value;
+ }
+ }
+
+ private final BjorneContext context;
+ private final Deque<Integer> opStack = new ArrayDeque<Integer>();
+ private final Deque<Primary> valStack = new ArrayDeque<Primary>();
+
+
+ public BjorneArithmeticEvaluator(BjorneContext context) {
+ super();
+ this.context = context;
+ }
+
+ protected synchronized String evaluateExpression(CharSequence source)
+ throws ShellException {
+ opStack.clear();
+ valStack.clear();
+ CharIterator ci = new CharIterator(source);
+ Primary res = evalExpression(ci);
+ return Long.toString(res.getValue());
+ }
+
+ private Primary evalExpression(CharIterator ci) throws ShellException {
+ int ch = skipWhiteSpace(ci);
+ while ((ch = skipWhiteSpace(ci)) != -1 && ch != ')') {
+ int prefixOp = parseExpressionOperator(ci);
+ switch (prefixOp) {
+ case NONE:
+ break;
+ case PLUS:
+ case MINUS:
+ case PLUSPLUS:
+ case MINUSMINUS:
+ prefixOp += PREFIX;
+ break;
+ default:
+ throw new ShellSyntaxException("Unexpected infix operator");
+ }
+ skipWhiteSpace(ci);
+ pushOperand(evalPrimary(ci));
+ skipWhiteSpace(ci);
+ int op = parseExpressionOperator(ci);
+ if (prefixOp != NONE) {
+ if (op == PLUSPLUS || op == MINUSMINUS) {
+ pushOperator(op);
+ skipWhiteSpace(ci);
+ op = parseExpressionOperator(ci);
+ }
+ pushOperator(prefixOp);
+ }
+ ch = skipWhiteSpace(ci);
+ if (op == NONE) {
+ if (ch != -1 && ch != ')') {
+ throw new ShellSyntaxException("Expected an infix operator in expression");
+ }
+ break;
+ } else if (op == PLUSPLUS || op == MINUSMINUS) {
+ throw new ShellSyntaxException("Expected an infix operator in expression");
+ } else if (ch == ')') {
+ throw new ShellSyntaxException("Expected a number or variable name in expression");
+ }
+ pushOperator(op);
+ }
+ if (valStack.size() == 0) {
+ throw new ShellSyntaxException("No expression within \"$((...))\"");
+ }
+ while (!opStack.isEmpty()) {
+ evalOperation();
+ }
+ return valStack.getFirst();
+ }
+
+ private void pushOperator(int op) throws ShellException {
+ while (!opStack.isEmpty() && opStack.getFirst() <= op) {
+ evalOperation();
+ }
+ opStack.addFirst(op);
+ }
+
+ private void pushOperand(Primary operand) {
+ valStack.addFirst(operand);
+ }
+
+ private void evalOperation() throws ShellException {
+ Integer op = opStack.removeFirst();
+ Primary operand1;
+ Primary operand2;
+ if (unaryOps.contains(op)) {
+ operand1 = valStack.removeFirst();
+ operand2 = null;
+ } else {
+ System.err.println(op);
+ operand2 = valStack.removeFirst();
+ operand1 = valStack.removeFirst();
+ }
+ long value;
+ Primary res;
+ switch (op) {
+ case PLUS + PREFIX:
+ res = new Primary(null, operand1.getValue());
+ break;
+ case MINUS + PREFIX:
+ res = new Primary(null, -operand1.getValue());
+ break;
+ case PLUSPLUS + PREFIX:
+ case MINUSMINUS + PREFIX:
+ if (operand1.name == null) {
+ throw new ShellSyntaxException("Cannot apply ++ or -- to a number or a subexpression");
+ }
+ value = evalName(operand1.name) + (op == PLUSPLUS ? 1 : -1);
+ context.setVariable(operand1.name, Long.toString(value));
+ res = new Primary(null, value);
+ break;
+ case PLUSPLUS:
+ case MINUSMINUS:
+ if (operand1.name == null) {
+ throw new ShellSyntaxException("Cannot apply ++ or -- to a number or a subexpression");
+ }
+ value = evalName(operand1.name) + (op == PLUSPLUS ? 1 : -1);
+ context.setVariable(operand1.name, Long.toString(value));
+ res = new Primary(null, value);
+ break;
+ case PLUS:
+ res = new Primary(null, operand1.getValue() + operand2.getValue());
+ break;
+ case MINUS:
+ res = new Primary(null, operand1.getValue() - operand2.getValue());
+ break;
+ case STAR:
+ res = new Primary(null, operand1.getValue() * operand2.getValue());
+ break;
+ case STARSTAR:
+ res = new Primary(null, Math.round(Math.pow(operand1.getValue(), operand2.getValue())));
+ break;
+ case SLASH:
+ value = operand2.getValue();
+ if (value == 0) {
+ throw new ShellException("Divide by zero in expression");
+ }
+ res = new Primary(null, operand1.getValue() / value);
+ break;
+ case PERCENT:
+ value = operand2.getValue();
+ if (value == 0) {
+ throw new ShellException("Divide by zero in expression");
+ }
+ res = new Primary(null, operand1.getValue() % value);
+ break;
+ default:
+ throw new ShellFailureException("operator not supported");
+ }
+ valStack.addFirst(res);
+ }
+
+ private Primary evalPrimary(CharIterator ci) throws ShellException {
+ int ch = ci.peekCh();
+ if (Character.isLetter(ch) || ch == '_') {
+ return new Primary(context.parseParameter(ci), 0L);
+ } else if (Character.isDigit(ch)) {
+ return new Primary(null, parseNumber(ci));
+ } else if (ch == '(') {
+ ci.nextCh();
+ Primary res = evalExpression(ci);
+ if (ci.nextCh() != ')') {
+ throw new ShellSyntaxException("Unmatched \"(\" (left parenthesis) in arithmetic expression");
+ }
+ return res;
+ } else {
+ throw new ShellSyntaxException("Expected a number or variable name");
+ }
+ }
+
+ private long evalName(String name) throws ShellSyntaxException {
+ try {
+ String value = context.variable(name);
+ return value == null ? 0L : Long.parseLong(value);
+ } catch (NumberFormatException ex) {
+ throw new ShellSyntaxException(
+ "expression syntax error: '" + context.variable(name) + "' is not an integer");
+ }
+ }
+
+ private int skipWhiteSpace(CharIterator ci) {
+ int ch = ci.peekCh();
+ while (ch == ' ' || ch == '\t' || ch == '\n') {
+ ci.nextCh();
+ ch = ci.peekCh();
+ }
+ return ch;
+ }
+
+ private int parseExpressionOperator(CharIterator ci) throws ShellSyntaxException {
+ int ch = ci.peekCh();
+ switch (ch) {
+ case '+':
+ ci.nextCh();
+ if (ci.peekCh() == '+') {
+ ci.nextCh();
+ return PLUSPLUS;
+ } else {
+ return PLUS;
+ }
+ case '-':
+ ci.nextCh();
+ if (ci.peekCh() == '-') {
+ ci.nextCh();
+ return MINUSMINUS;
+ } else {
+ return MINUS;
+ }
+ case '/':
+ ci.nextCh();
+ return SLASH;
+ case '*':
+ ci.nextCh();
+ return STAR;
+ case '%':
+ ci.nextCh();
+ return PERCENT;
+ default:
+ return NONE;
+ }
+ }
+
+ private long parseNumber(CharIterator ci) {
+ StringBuilder sb = new StringBuilder();
+ int ch;
+ while (Character.isDigit((char) (ch = ci.nextCh()))) {
+ sb.append((char) ch);
+ }
+ return Long.parseLong(sb.toString());
+ }
+}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-08-16 15:07:51 UTC (rev 5655)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-08-20 11:24:38 UTC (rev 5656)
@@ -17,7 +17,6 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
package org.jnode.shell.bjorne;
import org.jnode.shell.AbstractCommand;
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-16 15:07:51 UTC (rev 5655)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-20 11:24:38 UTC (rev 5656)
@@ -74,29 +74,17 @@
public class BjorneContext {
private static final int NONE = 1;
-
private static final int HASH = 2;
-
private static final int DHASH = 3;
-
private static final int PERCENT = 4;
-
private static final int DPERCENT = 5;
-
- private static final int HYPHEN = 6;
-
- private static final int COLONHYPHEN = 7;
-
+ private static final int MINUS = 6;
+ private static final int COLONMINUS = 7;
private static final int EQUALS = 8;
-
private static final int COLONEQUALS = 9;
-
private static final int PLUS = 10;
-
private static final int COLONPLUS = 11;
-
private static final int QUERY = 12;
-
private static final int COLONQUERY = 13;
private final BjorneInterpreter interpreter;
@@ -835,7 +823,7 @@
operator = COLONQUERY;
break;
case '-':
- operator = COLONHYPHEN;
+ operator = COLONMINUS;
break;
default:
throw new ShellSyntaxException("bad substitution operator");
@@ -852,7 +840,7 @@
operator = PLUS;
break;
case '-':
- operator = HYPHEN;
+ operator = MINUS;
break;
default:
throw new ShellSyntaxException("unrecognized substitution operator (\"" + (char) ch + "\")");
@@ -866,9 +854,9 @@
throw new ShellSyntaxException("Unmatched \"{\"");
}
switch (operator) {
- case HYPHEN:
+ case MINUS:
return (value == null) ? word : value;
- case COLONHYPHEN:
+ case COLONMINUS:
return (value == null || value.length() == 0) ? word : value;
case PLUS:
return (value == null) ? "" : word;
@@ -917,7 +905,7 @@
}
}
- private String parseParameter(CharIterator ci) throws ShellSyntaxException {
+ String parseParameter(CharIterator ci) throws ShellSyntaxException {
StringBuilder sb = new StringBuilder();
int ch = ci.peekCh();
while (Character.isLetterOrDigit((char) ch) || ch == '_') {
@@ -1040,82 +1028,45 @@
return runBacktickCommand(commandLine);
}
}
-
- private CharSequence dollarParenParenExpand(CharIterator ci) {
- // TODO Auto-generated method stub
- return null;
+
+ private CharSequence dollarParenParenExpand(CharIterator ci) throws ShellException {
+ // Different shells handle $(( ... )) differently, but dash seems to do what
+ // the POSIX spec seems to say. In the first phase, we look for the matching '))'
+ // keeping track of nested parentheses and performing any $ expansions. Double
+ // quotes should be treated as literal.
+ StringBuilder sb = new StringBuilder();
+ int nesting = 0;
+ boolean done = false;
+ do {
+ int ch = ci.peekCh();
+ switch (ch) {
+ case '(':
+ nesting++;
+ sb.append('(');
+ break;
+ case ')':
+ if (nesting > 0) {
+ nesting--;
+ sb.append(')');
+ } else if (ci.peekCh() == ')') {
+ ci.nextCh();
+ done = true;
+ } else {
+ sb.append(')');
+ }
+ break;
+ case '$':
+ sb.append(dollarExpand(ci, '\000'));
+ break;
+ case -1:
+ throw new ShellSyntaxException("Unmatched \"((\" (double left parenthesis)");
+ default:
+ sb.append((char) ch);
+ }
+ } while (!done);
+ return new BjorneArithmeticEvaluator(this).evaluateExpression(sb);
}
-// private String dollarParenExpand(CharIterator ci) throws ShellException {
-// StringBuilder sb = extractToMatchingParen(ci);
-// if (sb.length() > 0 && sb.charAt(sb.length()) == ')') {
-// throw new ShellSyntaxException(
-// "There should be a space between the two ')'s in '$(...))'");
-// }
-// return runBacktickCommand(sb.toString()).toString();
-// }
-//
-// private StringBuilder extractToMatchingParen(CharIterator ci) throws ShellSyntaxException {
-// StringBuilder sb = new StringBuilder(40);
-// Deque<Character> stack = new ArrayDeque<Character>();
-// int ch;
-// boolean more = true;
-// do {
-// ch = ci.nextCh();
-// switch (ch) {
-// case -1:
-// if (!stack.isEmpty()) {
-// throw new ShellSyntaxException("unmatched '('");
-// }
-// more = false;
-// break;
-// case ')':
-// if (stack.isEmpty()) {
-// more = false;
-// } else {
-// sb.append(')');
-// if (stack.peekFirst() == '(') {
-// stack.removeFirst();
-// }
-// }
-// break;
-// case '(':
-// if (stack.isEmpty() || stack.peekFirst() == '(') {
-// stack.addFirst('(');
-// }
-// sb.append('(');
-// break;
-// case '"':
-// case '\'':
-// case '`':
-// sb.append((char) ch);
-// if (stack.isEmpty()) {
-// stack.addFirst((char) ch);
-// } else {
-// char top = stack.peekFirst();
-// if (top != '"' && top != '\'' && top != '`') {
-// stack.addFirst('"');
-// } else if (top == ch) {
-// stack.removeFirst();
-// }
-// }
-// break;
-// case '\\':
-// sb.append('\\');
-// ch = ci.nextCh();
-// if (ch == -1) {
-// more = false;
-// } else {
-// sb.append((char) ch);
-// }
-// break;
-// default:
-// sb.append((char) ch);
-// }
-// } while (more);
-// return sb;
-// }
-
int execute(CommandLine command, CommandIO[] streams, boolean isBuiltin) throws ShellException {
if (isEchoExpansions()) {
StringBuilder sb = new StringBuilder();
Added: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneArithmeticEvaluatorTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneArithmeticEvaluatorTest.java (rev 0)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneArithmeticEvaluatorTest.java 2009-08-20 11:24:38 UTC (rev 5656)
@@ -0,0 +1,100 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2003-2009 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.jnode.test.shell.bjorne;
+
+import junit.framework.TestCase;
+
+import org.jnode.shell.ShellException;
+import org.jnode.shell.bjorne.BjorneArithmeticEvaluator;
+import org.jnode.shell.bjorne.BjorneContext;
+import org.jnode.shell.io.CommandIOHolder;
+
+/**
+ * Some unit tests for the BjorneArithmeticEvaluator class.
+ *
+ * @author cr...@jn...
+ */
+public class BjorneArithmeticEvaluatorTest extends TestCase {
+
+ // This class simply allows us to call the setVariable method directly
+ private static class TestBjorneContext extends BjorneContext {
+ TestBjorneContext(CommandIOHolder[] holders) {
+ super(null, holders);
+ }
+
+ TestBjorneContext() {
+ super(null, null);
+ }
+
+ /**
+ * Expose method for testing
+ */
+ @Override
+ protected void setVariable(String name, String value) {
+ super.setVariable(name, value);
+ }
+ }
+
+ private static class TestBjorneArithmeticEvaluator extends BjorneArithmeticEvaluator {
+ public TestBjorneArithmeticEvaluator(BjorneContext context) {
+ super(context);
+ }
+
+ @Override
+ public synchronized String evaluateExpression(CharSequence source) throws ShellException {
+ return super.evaluateExpression(source);
+ }
+ }
+
+
+ public void testConstructor() {
+ new BjorneArithmeticEvaluator(new TestBjorneContext());
+ }
+
+ public void testLiterals() throws ShellException {
+ TestBjorneArithmeticEvaluator ev = new TestBjorneArithmeticEvaluator(new TestBjorneContext());
+ assertEquals("1", ev.evaluateExpression("1"));
+ assertEquals("1", ev.evaluateExpression(" 1 "));
+ assertEquals("42", ev.evaluateExpression("42"));
+ }
+
+ public void testVariable() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext();
+ context.setVariable("A", "1");
+ TestBjorneArithmeticEvaluator ev = new TestBjorneArithmeticEvaluator(context);
+ assertEquals("1", ev.evaluateExpression("A"));
+ assertEquals("1", ev.evaluateExpression(" A "));
+ assertEquals("0", ev.evaluateExpression(" B"));
+ }
+
+ public void testUnaryPlusMinus() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext();
+ context.setVariable("A", "1");
+ TestBjorneArithmeticEvaluator ev = new TestBjorneArithmeticEvaluator(context);
+ assertEquals("1", ev.evaluateExpression("+A"));
+ assertEquals("1", ev.evaluateExpression(" + A "));
+ assertEquals("0", ev.evaluateExpression(" + B"));
+ assertEquals("-1", ev.evaluateExpression("-A"));
+ assertEquals("-1", ev.evaluateExpression(" - A "));
+ assertEquals("0", ev.evaluateExpression(" - B"));
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-08-20 15:32:02
|
Revision: 5657
http://jnode.svn.sourceforge.net/jnode/?rev=5657&view=rev
Author: crawley
Date: 2009-08-20 15:31:54 +0000 (Thu, 20 Aug 2009)
Log Message:
-----------
More work on the expression evaluator.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneArithmeticEvaluator.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneArithmeticEvaluatorTest.java
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneArithmeticEvaluator.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneArithmeticEvaluator.java 2009-08-20 11:24:38 UTC (rev 5656)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneArithmeticEvaluator.java 2009-08-20 15:31:54 UTC (rev 5657)
@@ -90,6 +90,15 @@
public long getValue() throws ShellSyntaxException {
return name != null ? evalName(name) : value;
}
+
+ @Override
+ public String toString() {
+ try {
+ return Long.toString(getValue());
+ } catch (ShellException ex) {
+ return "OOPS";
+ }
+ }
}
private final BjorneContext context;
@@ -112,6 +121,7 @@
}
private Primary evalExpression(CharIterator ci) throws ShellException {
+ int mark = opStack.size();
int ch = skipWhiteSpace(ci);
while ((ch = skipWhiteSpace(ci)) != -1 && ch != ')') {
int prefixOp = parseExpressionOperator(ci);
@@ -129,16 +139,17 @@
}
skipWhiteSpace(ci);
pushOperand(evalPrimary(ci));
+ if (prefixOp != NONE) {
+ pushOperator(prefixOp, mark);
+ }
skipWhiteSpace(ci);
int op = parseExpressionOperator(ci);
- if (prefixOp != NONE) {
- if (op == PLUSPLUS || op == MINUSMINUS) {
- pushOperator(op);
- skipWhiteSpace(ci);
- op = parseExpressionOperator(ci);
- }
- pushOperator(prefixOp);
+ if (op == PLUSPLUS || op == MINUSMINUS) {
+ pushOperator(op, mark);
+ skipWhiteSpace(ci);
+ op = parseExpressionOperator(ci);
}
+
ch = skipWhiteSpace(ci);
if (op == NONE) {
if (ch != -1 && ch != ')') {
@@ -150,19 +161,19 @@
} else if (ch == ')') {
throw new ShellSyntaxException("Expected a number or variable name in expression");
}
- pushOperator(op);
+ pushOperator(op, mark);
}
if (valStack.size() == 0) {
throw new ShellSyntaxException("No expression within \"$((...))\"");
}
- while (!opStack.isEmpty()) {
+ while (opStack.size() > mark) {
evalOperation();
}
- return valStack.getFirst();
+ return valStack.removeFirst();
}
- private void pushOperator(int op) throws ShellException {
- while (!opStack.isEmpty() && opStack.getFirst() <= op) {
+ private void pushOperator(int op, int mark) throws ShellException {
+ while (opStack.size() > mark && precedence.get(opStack.getFirst()) <= precedence.get(op)) {
evalOperation();
}
opStack.addFirst(op);
@@ -180,7 +191,6 @@
operand1 = valStack.removeFirst();
operand2 = null;
} else {
- System.err.println(op);
operand2 = valStack.removeFirst();
operand1 = valStack.removeFirst();
}
@@ -198,7 +208,7 @@
if (operand1.name == null) {
throw new ShellSyntaxException("Cannot apply ++ or -- to a number or a subexpression");
}
- value = evalName(operand1.name) + (op == PLUSPLUS ? 1 : -1);
+ value = evalName(operand1.name) + (op == PLUSPLUS + PREFIX ? 1 : -1);
context.setVariable(operand1.name, Long.toString(value));
res = new Primary(null, value);
break;
@@ -207,8 +217,8 @@
if (operand1.name == null) {
throw new ShellSyntaxException("Cannot apply ++ or -- to a number or a subexpression");
}
- value = evalName(operand1.name) + (op == PLUSPLUS ? 1 : -1);
- context.setVariable(operand1.name, Long.toString(value));
+ value = evalName(operand1.name);
+ context.setVariable(operand1.name, Long.toString(value + (op == PLUSPLUS ? 1 : -1)));
res = new Primary(null, value);
break;
case PLUS:
@@ -233,7 +243,7 @@
case PERCENT:
value = operand2.getValue();
if (value == 0) {
- throw new ShellException("Divide by zero in expression");
+ throw new ShellException("Remainder by zero in expression");
}
res = new Primary(null, operand1.getValue() % value);
break;
@@ -252,7 +262,8 @@
} else if (ch == '(') {
ci.nextCh();
Primary res = evalExpression(ci);
- if (ci.nextCh() != ')') {
+ skipWhiteSpace(ci);
+ if ((ch = ci.nextCh()) != ')') {
throw new ShellSyntaxException("Unmatched \"(\" (left parenthesis) in arithmetic expression");
}
return res;
@@ -304,7 +315,12 @@
return SLASH;
case '*':
ci.nextCh();
- return STAR;
+ if (ci.peekCh() == '*') {
+ ci.nextCh();
+ return STARSTAR;
+ } else {
+ return STAR;
+ }
case '%':
ci.nextCh();
return PERCENT;
@@ -315,9 +331,11 @@
private long parseNumber(CharIterator ci) {
StringBuilder sb = new StringBuilder();
- int ch;
- while (Character.isDigit((char) (ch = ci.nextCh()))) {
+ int ch = ci.peekCh();
+ while (ch != -1 && Character.isDigit((char) ch)) {
+ ci.nextCh();
sb.append((char) ch);
+ ch = ci.peekCh();
}
return Long.parseLong(sb.toString());
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-20 11:24:38 UTC (rev 5656)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-20 15:31:54 UTC (rev 5657)
@@ -951,8 +951,7 @@
return sb.toString();
}
-
- String variable(String parameter) throws ShellSyntaxException {
+ protected String variable(String parameter) throws ShellSyntaxException {
if (BjorneToken.isName(parameter)) {
VariableSlot var = variables.get(parameter);
return (var != null) ? var.getValue() : null;
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneArithmeticEvaluatorTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneArithmeticEvaluatorTest.java 2009-08-20 11:24:38 UTC (rev 5656)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneArithmeticEvaluatorTest.java 2009-08-20 15:31:54 UTC (rev 5657)
@@ -23,6 +23,7 @@
import junit.framework.TestCase;
import org.jnode.shell.ShellException;
+import org.jnode.shell.ShellSyntaxException;
import org.jnode.shell.bjorne.BjorneArithmeticEvaluator;
import org.jnode.shell.bjorne.BjorneContext;
import org.jnode.shell.io.CommandIOHolder;
@@ -44,13 +45,15 @@
super(null, null);
}
- /**
- * Expose method for testing
- */
@Override
protected void setVariable(String name, String value) {
super.setVariable(name, value);
}
+
+ @Override
+ protected String variable(String name) throws ShellSyntaxException {
+ return super.variable(name);
+ }
}
private static class TestBjorneArithmeticEvaluator extends BjorneArithmeticEvaluator {
@@ -97,4 +100,65 @@
assertEquals("0", ev.evaluateExpression(" - B"));
}
+ public void testInfixOperators() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext();
+ context.setVariable("A", "1");
+ TestBjorneArithmeticEvaluator ev = new TestBjorneArithmeticEvaluator(context);
+ assertEquals("2", ev.evaluateExpression("1 + 1"));
+ assertEquals("2", ev.evaluateExpression("A + 1"));
+ assertEquals("0", ev.evaluateExpression("1 - 1"));
+ assertEquals("0", ev.evaluateExpression("1 - A"));
+ assertEquals("4", ev.evaluateExpression("2 * 2"));
+ assertEquals("2", ev.evaluateExpression("4 / 2"));
+ assertEquals("1", ev.evaluateExpression("4 % 3"));
+ assertEquals("27", ev.evaluateExpression("3 ** 3"));
+ try {
+ ev.evaluateExpression("4 / 0");
+ fail("no exception for '4 / 0'");
+ } catch (ShellException ex) {
+ // expected
+ }
+ try {
+ ev.evaluateExpression("4 % 0");
+ fail("no exception for '4 % 0'");
+ } catch (ShellException ex) {
+ // expected
+ }
+ }
+
+ public void testInfixPrecedence() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext();
+ context.setVariable("A", "1");
+ TestBjorneArithmeticEvaluator ev = new TestBjorneArithmeticEvaluator(context);
+ assertEquals("0", ev.evaluateExpression("-1 * 2 + 2"));
+ assertEquals("4", ev.evaluateExpression("1 * 2 + 2"));
+ assertEquals("5", ev.evaluateExpression("1 + 2 * 2"));
+ assertEquals("9", ev.evaluateExpression("1 + 2 * 2 ** 2"));
+ assertEquals("8", ev.evaluateExpression("1 + 2 * 2 ** 2 + -A"));
+ }
+
+ public void testParentheses() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext();
+ context.setVariable("A", "1");
+ TestBjorneArithmeticEvaluator ev = new TestBjorneArithmeticEvaluator(context);
+ assertEquals("-4", ev.evaluateExpression("-1 * (2 + 2)"));
+ assertEquals("4", ev.evaluateExpression("(1 * 2 + 2)"));
+ assertEquals("6", ev.evaluateExpression("((1) + 2) * 2"));
+ assertEquals("17", ev.evaluateExpression("1 + (2 * 2) ** 2"));
+ assertEquals("10", ev.evaluateExpression("1 + 2 * 2 ** 2 + -(-1)"));
+ }
+
+ public void testIncDec() throws ShellException {
+ TestBjorneContext context = new TestBjorneContext();
+ context.setVariable("A", "1");
+ TestBjorneArithmeticEvaluator ev = new TestBjorneArithmeticEvaluator(context);
+ assertEquals("1", ev.evaluateExpression("A++"));
+ assertEquals("2", context.variable("A"));
+ assertEquals("3", ev.evaluateExpression("++A"));
+ assertEquals("3", context.variable("A"));
+ assertEquals("3", ev.evaluateExpression("A--"));
+ assertEquals("2", context.variable("A"));
+ assertEquals("1", ev.evaluateExpression("--A"));
+ assertEquals("1", context.variable("A"));
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-08-21 13:24:47
|
Revision: 5658
http://jnode.svn.sourceforge.net/jnode/?rev=5658&view=rev
Author: crawley
Date: 2009-08-21 13:24:37 +0000 (Fri, 21 Aug 2009)
Log Message:
-----------
Arithmetic Expression evaluation using $((...)) now works ... modulo
that the POSIX spec is so unclear that it is difficult to figure
out exactly what is correct in edge-cases.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-20 15:31:54 UTC (rev 5657)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-21 13:24:37 UTC (rev 5658)
@@ -1029,10 +1029,6 @@
}
private CharSequence dollarParenParenExpand(CharIterator ci) throws ShellException {
- // Different shells handle $(( ... )) differently, but dash seems to do what
- // the POSIX spec seems to say. In the first phase, we look for the matching '))'
- // keeping track of nested parentheses and performing any $ expansions. Double
- // quotes should be treated as literal.
StringBuilder sb = new StringBuilder();
int nesting = 0;
boolean done = false;
@@ -1054,16 +1050,15 @@
sb.append(')');
}
break;
- case '$':
- sb.append(dollarExpand(ci, '\000'));
- break;
case -1:
throw new ShellSyntaxException("Unmatched \"((\" (double left parenthesis)");
default:
sb.append((char) ch);
}
+ ci.nextCh();
} while (!done);
- return new BjorneArithmeticEvaluator(this).evaluateExpression(sb);
+ CharSequence tmp = dollarBacktickExpand(new CharIterator(sb), '\000');
+ return new BjorneArithmeticEvaluator(this).evaluateExpression(tmp);
}
int execute(CommandLine command, CommandIO[] streams, boolean isBuiltin) throws ShellException {
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-08-20 15:31:54 UTC (rev 5657)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-08-21 13:24:37 UTC (rev 5658)
@@ -98,6 +98,20 @@
1 1
</output>
</testSpec>
+ <testSpec title="$((...))" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+A=1
+echo $A
+B="$((A + 1))"
+echo $B
+C="$(($B + 1))"
+echo $C
+</script>
+ <output>1
+2
+3
+</output>
+ </testSpec>
<testSpec title="if ... then ... fi" command="test" runMode="AS_SCRIPT" rc="0">
<script>#!bjorne
if true ; then echo HI ; fi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-08-22 14:37:48
|
Revision: 5659
http://jnode.svn.sourceforge.net/jnode/?rev=5659&view=rev
Author: crawley
Date: 2009-08-22 14:37:39 +0000 (Sat, 22 Aug 2009)
Log Message:
-----------
Partial implementation of shell functions. (Arguments, redirections and
the context / variables are not yet implemented when a function is run.)
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-08-21 13:24:37 UTC (rev 5658)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-08-22 14:37:39 UTC (rev 5659)
@@ -48,12 +48,6 @@
/**
* Temporary adapter method. Unconverted builtin classes override this.
- *
- * @param command
- * @param interpreter
- * @param context
- * @return
- * @throws ShellException
*/
int invoke(CommandLine command, BjorneInterpreter interpreter,
BjorneContext context) throws ShellException {
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-21 13:24:37 UTC (rev 5658)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-22 14:37:39 UTC (rev 5659)
@@ -90,8 +90,10 @@
private final BjorneInterpreter interpreter;
private Map<String, VariableSlot> variables;
+
+ private TreeMap<String, String> aliases;
- private TreeMap<String, String> aliases;
+ private TreeMap<String, CommandNode> functions;
private String command = "";
@@ -122,6 +124,7 @@
this.holders = holders;
this.variables = new HashMap<String, VariableSlot>();
this.aliases = new TreeMap<String, String>();
+ this.functions = new TreeMap<String, CommandNode>();
initVariables();
}
@@ -157,6 +160,7 @@
this.holders = copyStreamHolders(parent.holders);
this.variables = copyVariables(parent.variables);
this.aliases = new TreeMap<String, String>(parent.aliases);
+ this.functions = new TreeMap<String, CommandNode>(parent.functions);
this.globbing = parent.globbing;
this.tildeExpansion = parent.tildeExpansion;
this.echoExpansions = parent.echoExpansions;
@@ -406,15 +410,8 @@
* @param tokens the tokens to be expanded and split into words
* @throws ShellException
*/
- public List<BjorneToken> expandAndSplit(BjorneToken ... tokens)
- throws ShellException {
- List<BjorneToken> wordTokens = new LinkedList<BjorneToken>();
- for (BjorneToken token : tokens) {
- dollarBacktickSplit(token, wordTokens);
- }
- wordTokens = fileExpand(wordTokens);
- wordTokens = dequote(wordTokens);
- return wordTokens;
+ public List<BjorneToken> expandAndSplit(BjorneToken ... tokens) throws ShellException {
+ return expandAndSplit(Arrays.asList(tokens));
}
/**
@@ -1061,7 +1058,7 @@
return new BjorneArithmeticEvaluator(this).evaluateExpression(tmp);
}
- int execute(CommandLine command, CommandIO[] streams, boolean isBuiltin) throws ShellException {
+ int execute(CommandLine command, CommandIO[] streams) throws ShellException {
if (isEchoExpansions()) {
StringBuilder sb = new StringBuilder();
sb.append(" + ").append(command.getCommandName());
@@ -1071,7 +1068,7 @@
resolvePrintStream(streams[Command.STD_ERR]).println(sb);
}
Map<String, String> env = buildEnvFromExports();
- lastReturnCode = interpreter.executeCommand(command, this, streams, null, env, isBuiltin);
+ lastReturnCode = interpreter.executeCommand(command, this, streams, null, env);
return lastReturnCode;
}
@@ -1390,4 +1387,12 @@
return variables.keySet();
}
+ void defineFunction(BjorneToken name, CommandNode body) {
+ functions.put(name.getText(), body);
+ }
+
+ CommandNode getFunction(String name) {
+ return functions.get(name);
+ }
+
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-08-21 13:24:37 UTC (rev 5658)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-08-22 14:37:39 UTC (rev 5659)
@@ -122,7 +122,7 @@
public static final int FLAG_PIPE = 0x0010;
public static final CommandNode EMPTY =
- new SimpleCommandNode(CMD_EMPTY, new BjorneToken[0], false);
+ new SimpleCommandNode(CMD_EMPTY, new BjorneToken[0]);
static HashMap<String, BjorneBuiltin.Factory> BUILTINS =
new HashMap<String, BjorneBuiltin.Factory>();
@@ -313,13 +313,19 @@
}
int executeCommand(CommandLine cmdLine, BjorneContext context, CommandIO[] streams,
- Properties sysProps, Map<String, String> env, boolean isBuiltin)
+ Properties sysProps, Map<String, String> env)
throws ShellException {
- if (isBuiltin) {
- BjorneBuiltinCommandInfo builtin =
- BUILTINS.get(cmdLine.getCommandName()).buildCommandInfo(context);
+ String commandName = cmdLine.getCommandName();
+ if (isBuiltin(commandName)) {
+ BjorneBuiltinCommandInfo builtin = BUILTINS.get(commandName).buildCommandInfo(context);
cmdLine.setCommandInfo(builtin);
- }
+ } else {
+ CommandNode body = context.getFunction(commandName);
+ if (body != null) {
+ // FIXME setup a new context, streams and args.
+ return body.execute(context);
+ }
+ }
cmdLine.setStreams(streams);
return shell.invoke(cmdLine, sysProps, env);
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-08-21 13:24:37 UTC (rev 5658)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-08-22 14:37:39 UTC (rev 5659)
@@ -145,7 +145,7 @@
} else {
noLineBreaks();
if (optNext(TOK_END_OF_LINE_BIT) != null) {
- command = new SimpleCommandNode(CMD_COMMAND, new BjorneToken[0], false);
+ command = new SimpleCommandNode(CMD_COMMAND, new BjorneToken[0]);
}
}
return command;
@@ -292,7 +292,6 @@
List<BjorneToken> assignments = new LinkedList<BjorneToken>();
List<RedirectionNode> redirects = new LinkedList<RedirectionNode>();
List<BjorneToken> words = new LinkedList<BjorneToken>();
- boolean builtin = false;
// Deal with cmd_prefix'es before the command name; i.e. assignments and
// redirections
@@ -338,21 +337,17 @@
redirects.add(parseRedirect());
}
}
- String commandWord = words.get(0).getText();
- builtin = BjorneInterpreter.isBuiltin(commandWord);
- // FIXME ... built-in commands should use the Syntax mechanisms so
- // that completion, help, etc will work as expected.
}
} catch (ShellSyntaxException ex) {
if (completer != null) {
completer.setCommand(words.size() == 0 ? null :
new SimpleCommandNode(CMD_COMMAND,
- words.toArray(new BjorneToken[words.size()]), builtin));
+ words.toArray(new BjorneToken[words.size()])));
}
throw ex;
}
SimpleCommandNode res = new SimpleCommandNode(CMD_COMMAND,
- words.toArray(new BjorneToken[words.size()]), builtin);
+ words.toArray(new BjorneToken[words.size()]));
if (completer != null) {
completer.setCommand(words.size() == 0 ? null : res);
}
@@ -382,8 +377,6 @@
}
private CommandNode parseFunctionBody() throws ShellSyntaxException {
- // TODO ... need to set the context to 'rule 9' while parsing the
- // function body
CommandNode body = parseCompoundCommand();
body.setRedirects(parseOptRedirects());
return body;
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java 2009-08-21 13:24:37 UTC (rev 5658)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java 2009-08-22 14:37:39 UTC (rev 5659)
@@ -56,7 +56,8 @@
@Override
public int execute(BjorneContext context) {
- return -1;
+ context.defineFunction(name, body);
+ return 0;
}
@Override
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-08-21 13:24:37 UTC (rev 5658)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-08-22 14:37:39 UTC (rev 5659)
@@ -38,12 +38,10 @@
private final BjorneToken[] words;
- private final boolean builtin;
- public SimpleCommandNode(int nodeType, BjorneToken[] words, boolean builtin) {
+ public SimpleCommandNode(int nodeType, BjorneToken[] words) {
super(nodeType);
this.words = words;
- this.builtin = builtin;
}
public void setAssignments(BjorneToken[] assignments) {
@@ -58,10 +56,6 @@
return assignments;
}
- public boolean isBuiltin() {
- return builtin;
- }
-
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("SimpleCommand{").append(super.toString());
@@ -69,9 +63,6 @@
sb.append(",assignments=");
appendArray(sb, assignments);
}
- if (builtin) {
- sb.append(",builtin=true");
- }
if (words != null) {
sb.append(",words=");
appendArray(sb, words);
@@ -110,7 +101,7 @@
throw new ShellFailureException(
"asynchronous execution (&) not implemented yet");
} else {
- rc = childContext.execute(command, ios, builtin);
+ rc = childContext.execute(command, ios);
}
}
} catch (BjorneControlException ex) {
@@ -153,9 +144,10 @@
throws CompletionException {
try {
CommandLine command = context.buildCommandLine(words);
- if (builtin) {
+ String commandName = command.getCommandName();
+ if (commandName != null && BjorneInterpreter.isBuiltin(commandName)) {
BjorneBuiltinCommandInfo commandInfo =
- BjorneInterpreter.BUILTINS.get(command.getCommandName()).buildCommandInfo(context);
+ BjorneInterpreter.BUILTINS.get(commandName).buildCommandInfo(context);
command.setCommandInfo(commandInfo);
}
command.setArgumentAnticipated(argumentAnticipated);
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml 2009-08-21 13:24:37 UTC (rev 5658)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-builtin-tests.xml 2009-08-22 14:37:39 UTC (rev 5659)
@@ -74,26 +74,6 @@
<output>fred='ls'
</output>
</testSpec>
- <testSpec title="builtins recognized early" command="test" runMode="AS_SCRIPT" rc="0">
- <script>#!bjorne
- alias fred=ls
- alias
- unalias -a
- echo done
- UNALIAS=unalias
- alias fred=dir
- alias
- $UNALIAS -a
- echo done
- </script>
- <output>fred='ls'
-done
-fred='dir'
-done
-</output>
- <error>Cannot find an alias or load a command class for 'unalias'
-</error>
- </testSpec>
<testSpec title="readonly" runMode="AS_SCRIPT" rc="0">
<script>#!bjorne
readonly A
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-08-21 13:24:37 UTC (rev 5658)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-08-22 14:37:39 UTC (rev 5659)
@@ -969,4 +969,14 @@
<error>Cannot find an alias or load a command class for 'foo'
</error>
</testSpec>
+ <testSpec title="shell function" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ foo() {
+ echo hi
+ }
+ foo
+ </script>
+ <output >hi
+</output>
+ </testSpec>
</testSet>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2009-08-24 14:11:24
|
Revision: 5661
http://jnode.svn.sourceforge.net/jnode/?rev=5661&view=rev
Author: crawley
Date: 2009-08-24 14:11:14 +0000 (Mon, 24 Aug 2009)
Log Message:
-----------
Shell functions now support arguments and redirection
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-24 10:52:13 UTC (rev 5660)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-08-24 14:11:14 UTC (rev 5661)
@@ -1183,6 +1183,27 @@
}
/**
+ * Evaluate the redirections for this command against a set of streams, saving the context's existing IOs.
+ *
+ * @param redirects the redirection nodes to be evaluated
+ * @param streams the base CommandIOs for the redirection calculation.
+ * @throws ShellException
+ */
+ void evaluateRedirectionsAndPushHolders(RedirectionNode[] redirects, CommandIO[] streams)
+ throws ShellException {
+ if (savedHolders == null) {
+ savedHolders = new ArrayList<CommandIOHolder[]>(1);
+ }
+ savedHolders.add(holders);
+ holders = new CommandIOHolder[streams.length];
+ for (int i = 0; i < holders.length; i++) {
+ // Don't take ownership of the streams.
+ holders[i] = new CommandIOHolder(streams[i], false);
+ }
+ evaluateRedirections(redirects, holders);
+ }
+
+ /**
* Close the context's current IO, restoring the previous ones.
* @throws ShellException
*/
@@ -1199,8 +1220,8 @@
* @return the stream state after redirections
* @throws ShellException
*/
- void evaluateRedirections(
- RedirectionNode[] redirects, CommandIOHolder[] holders) throws ShellException {
+ void evaluateRedirections(RedirectionNode[] redirects, CommandIOHolder[] holders)
+ throws ShellException {
if (redirects == null) {
return;
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-08-24 10:52:13 UTC (rev 5660)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-08-24 14:11:14 UTC (rev 5661)
@@ -322,27 +322,34 @@
} else {
CommandNode body = context.getFunction(commandName);
if (body != null) {
- // FIXME setup a new context, streams and args.
- return body.execute(context);
+ context.evaluateRedirectionsAndPushHolders(body.getRedirects(), streams);
+ String[] savedArgs = context.getArgs();
+ try {
+ context.setArgs(cmdLine.getArguments());
+ return body.execute(context);
+ } finally {
+ context.popHolders();
+ context.setArgs(savedArgs);
+ }
}
}
cmdLine.setStreams(streams);
return shell.invoke(cmdLine, sysProps, env);
}
- public BjorneContext createContext() throws ShellFailureException {
+ BjorneContext createContext() throws ShellFailureException {
return new BjorneContext(this);
}
- public CommandShell getShell() {
+ CommandShell getShell() {
return shell;
}
- public PrintStream resolvePrintStream(CommandIO commandIOIF) {
+ PrintStream resolvePrintStream(CommandIO commandIOIF) {
return shell.resolvePrintStream(commandIOIF);
}
- public InputStream resolveInputStream(CommandIO stream) {
+ InputStream resolveInputStream(CommandIO stream) {
return shell.resolveInputStream(stream);
}
@@ -350,7 +357,7 @@
return subshellCount++;
}
- public String getUniqueName() {
+ String getUniqueName() {
return getName() + "-" + getSubshellNumber();
}
}
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-08-24 10:52:13 UTC (rev 5660)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-08-24 14:11:14 UTC (rev 5661)
@@ -976,7 +976,20 @@
}
foo
</script>
- <output >hi
+ <output>hi
</output>
</testSpec>
+ <testSpec title="shell function 2" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+ foo() {
+ echo $1 $2
+ }
+ foo hi there
+ foo bye mum >&2
+ </script>
+ <output>hi there
+</output>
+ <error>bye mum
+</error>
+ </testSpec>
</testSet>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2010-01-03 13:32:19
|
Revision: 5713
http://jnode.svn.sourceforge.net/jnode/?rev=5713&view=rev
Author: lsantha
Date: 2010-01-03 13:32:10 +0000 (Sun, 03 Jan 2010)
Log Message:
-----------
Updated file headers.
Modified Paths:
--------------
trunk/shell/src/emu/org/jnode/emu/DeviceManager.java
trunk/shell/src/emu/org/jnode/emu/Emu.java
trunk/shell/src/emu/org/jnode/emu/EmuException.java
trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java
trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java
trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/BuiltinCommandInfo.java
trunk/shell/src/shell/org/jnode/shell/Command.java
trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java
trunk/shell/src/shell/org/jnode/shell/CommandInfo.java
trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java
trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/CommandLine.java
trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java
trunk/shell/src/shell/org/jnode/shell/CommandRunner.java
trunk/shell/src/shell/org/jnode/shell/CommandShell.java
trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java
trunk/shell/src/shell/org/jnode/shell/CommandThread.java
trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java
trunk/shell/src/shell/org/jnode/shell/Completable.java
trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java
trunk/shell/src/shell/org/jnode/shell/NoTokensAvailableException.java
trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java
trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java
trunk/shell/src/shell/org/jnode/shell/Shell.java
trunk/shell/src/shell/org/jnode/shell/ShellControlException.java
trunk/shell/src/shell/org/jnode/shell/ShellException.java
trunk/shell/src/shell/org/jnode/shell/ShellFailureException.java
trunk/shell/src/shell/org/jnode/shell/ShellInvocationException.java
trunk/shell/src/shell/org/jnode/shell/ShellManager.java
trunk/shell/src/shell/org/jnode/shell/ShellSyntaxException.java
trunk/shell/src/shell/org/jnode/shell/ShellUtils.java
trunk/shell/src/shell/org/jnode/shell/SimpleCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/SymbolSource.java
trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/ThreadExitListener.java
trunk/shell/src/shell/org/jnode/shell/alias/AliasManager.java
trunk/shell/src/shell/org/jnode/shell/alias/NoSuchAliasException.java
trunk/shell/src/shell/org/jnode/shell/alias/def/DefaultAliasManager.java
trunk/shell/src/shell/org/jnode/shell/bjorne/AliasBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/AssignmentArgument.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneAliasDefinitionArgument.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneAliasNameArgument.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneArithmeticEvaluator.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltinCommandInfo.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompletable.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompleter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjornePipeline.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneShellPlugin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneSubshellRunner.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BreakBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CaseItemNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CharIterator.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ColonBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ContinueBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ExportBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ReadBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ReadonlyBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/RedirectionNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ReturnBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SetBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SetFlagArgument.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ShiftBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SourceBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/UnaliasBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/UnsetBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/VariableNameArgument.java
trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java
trunk/shell/src/shell/org/jnode/shell/command/bsh/BshCommand.java
trunk/shell/src/shell/org/jnode/shell/command/driver/DeviceCommand.java
trunk/shell/src/shell/org/jnode/shell/command/driver/console/ClearConsoleCommand.java
trunk/shell/src/shell/org/jnode/shell/command/driver/console/ConsoleCommand.java
trunk/shell/src/shell/org/jnode/shell/command/driver/system/acpi/AcpiCommand.java
trunk/shell/src/shell/org/jnode/shell/command/driver/system/bus/SMBusCommand.java
trunk/shell/src/shell/org/jnode/shell/command/test/SuiteCommand.java
trunk/shell/src/shell/org/jnode/shell/command/test/TestCommand.java
trunk/shell/src/shell/org/jnode/shell/def/DefaultShellManager.java
trunk/shell/src/shell/org/jnode/shell/def/ShellPlugin.java
trunk/shell/src/shell/org/jnode/shell/help/CommandLineElement.java
trunk/shell/src/shell/org/jnode/shell/help/CompletionException.java
trunk/shell/src/shell/org/jnode/shell/help/EnhancedHelp.java
trunk/shell/src/shell/org/jnode/shell/help/Help.java
trunk/shell/src/shell/org/jnode/shell/help/HelpException.java
trunk/shell/src/shell/org/jnode/shell/help/HelpFactory.java
trunk/shell/src/shell/org/jnode/shell/help/def/DefaultHelpFactory.java
trunk/shell/src/shell/org/jnode/shell/help/def/NewSyntaxHelp.java
trunk/shell/src/shell/org/jnode/shell/help/def/SystemHelpPlugin.java
trunk/shell/src/shell/org/jnode/shell/help/def/TextHelpBase.java
trunk/shell/src/shell/org/jnode/shell/io/BaseCommandIO.java
trunk/shell/src/shell/org/jnode/shell/io/CommandIO.java
trunk/shell/src/shell/org/jnode/shell/io/CommandIOException.java
trunk/shell/src/shell/org/jnode/shell/io/CommandIOHolder.java
trunk/shell/src/shell/org/jnode/shell/io/CommandIOMarker.java
trunk/shell/src/shell/org/jnode/shell/io/CommandInput.java
trunk/shell/src/shell/org/jnode/shell/io/CommandInputOutput.java
trunk/shell/src/shell/org/jnode/shell/io/CommandOutput.java
trunk/shell/src/shell/org/jnode/shell/io/FanoutWriter.java
trunk/shell/src/shell/org/jnode/shell/io/NullInputStream.java
trunk/shell/src/shell/org/jnode/shell/io/NullOutputStream.java
trunk/shell/src/shell/org/jnode/shell/io/Pipeline.java
trunk/shell/src/shell/org/jnode/shell/io/PipelineInputStream.java
trunk/shell/src/shell/org/jnode/shell/io/PipelineOutputStream.java
trunk/shell/src/shell/org/jnode/shell/io/ShellConsoleReader.java
trunk/shell/src/shell/org/jnode/shell/io/ShellConsoleWriter.java
trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandLauncher.java
trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandThreadImpl.java
trunk/shell/src/shell/org/jnode/shell/isolate/IsolateSocket.java
trunk/shell/src/shell/org/jnode/shell/isolate/IsolateSocketImpl.java
trunk/shell/src/shell/org/jnode/shell/proclet/AbstractProxyPrintStream.java
trunk/shell/src/shell/org/jnode/shell/proclet/Proclet.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletException.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletIOContext.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyInputStream.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyPrintStream.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyStream.java
trunk/shell/src/shell/org/jnode/shell/syntax/AliasArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/AlternativesSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/Argument.java
trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentBundle.java
trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentSpecLoader.java
trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/ClassNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/CommandSyntaxException.java
trunk/shell/src/shell/org/jnode/shell/syntax/CountryArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/DefaultSyntaxManager.java
trunk/shell/src/shell/org/jnode/shell/syntax/DeviceArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/EmptySyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/EnumArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/FlagArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/GroupSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/HostNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/IntegerArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/KeyboardLayoutArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/LanguageArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLevelArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLoggerArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/LongArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/MappedArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuAlternation.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuBackReference.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuParser.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuPreset.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuSequence.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuSymbol.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/OptionSetSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/OptionSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/OptionalSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/PluginArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/PluginSyntaxSpecAdapter.java
trunk/shell/src/shell/org/jnode/shell/syntax/PortNumberArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/PowersetSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/PropertyNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/RepeatSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/SequenceSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/SharedStack.java
trunk/shell/src/shell/org/jnode/shell/syntax/ShellPropertyNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/StringArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/SymbolSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/Syntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxArgumentMissingException.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxBundle.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxFailureException.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxManager.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxMultiplicityException.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxSpecAdapter.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxSpecLoader.java
trunk/shell/src/shell/org/jnode/shell/syntax/SystemSyntaxPlugin.java
trunk/shell/src/shell/org/jnode/shell/syntax/ThreadNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/VerbSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/XMLSyntaxSpecAdapter.java
trunk/shell/src/test/org/jnode/test/shell/AllTests.java
trunk/shell/src/test/org/jnode/test/shell/Cassowary.java
trunk/shell/src/test/org/jnode/test/shell/CompletionHelper.java
trunk/shell/src/test/org/jnode/test/shell/CompletionInfoTest.java
trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java
trunk/shell/src/test/org/jnode/test/shell/DefaultSyntaxCompletionTest.java
trunk/shell/src/test/org/jnode/test/shell/DeviceManager.java
trunk/shell/src/test/org/jnode/test/shell/MyAliasCommand.java
trunk/shell/src/test/org/jnode/test/shell/MyCompileCommand.java
trunk/shell/src/test/org/jnode/test/shell/MyCpuIDCommand.java
trunk/shell/src/test/org/jnode/test/shell/MyDuhCommand.java
trunk/shell/src/test/org/jnode/test/shell/MyEchoCommand.java
trunk/shell/src/test/org/jnode/test/shell/PathnamePatternTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneArithmeticEvaluatorTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTest.java
trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java
trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java
trunk/shell/src/test/org/jnode/test/shell/harness/DummyPseudoPlugin.java
trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java
trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java
trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerException.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSetSpecification.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestsAbandonedException.java
trunk/shell/src/test/org/jnode/test/shell/harness/TextContent.java
trunk/shell/src/test/org/jnode/test/shell/help/DefaultHelpTest.java
trunk/shell/src/test/org/jnode/test/shell/io/PipelineTest.java
trunk/shell/src/test/org/jnode/test/shell/io/ReaderInputStreamTest.java
trunk/shell/src/test/org/jnode/test/shell/io/WriterOutputStreamTest.java
trunk/shell/src/test/org/jnode/test/shell/proclet/ProcletStreamTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/AllTests.java
trunk/shell/src/test/org/jnode/test/shell/syntax/AlternativesSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/ArgumentBundleTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/ArgumentMultiplicityTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/ArgumentTypesTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/CommandLineTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/DefaultTokenizerTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/MuParserTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/MuParserTest2.java
trunk/shell/src/test/org/jnode/test/shell/syntax/MuSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/OptionSetSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/OptionSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/PowersetSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/RepeatSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/SequenceSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/TestAliasManager.java
trunk/shell/src/test/org/jnode/test/shell/syntax/TestShell.java
trunk/shell/src/test/org/jnode/test/shell/syntax/TestSyntaxManager.java
Modified: trunk/shell/src/emu/org/jnode/emu/DeviceManager.java
===================================================================
--- trunk/shell/src/emu/org/jnode/emu/DeviceManager.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/emu/org/jnode/emu/DeviceManager.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/emu/org/jnode/emu/Emu.java
===================================================================
--- trunk/shell/src/emu/org/jnode/emu/Emu.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/emu/org/jnode/emu/Emu.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/emu/org/jnode/emu/EmuException.java
===================================================================
--- trunk/shell/src/emu/org/jnode/emu/EmuException.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/emu/org/jnode/emu/EmuException.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/BuiltinCommandInfo.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/BuiltinCommandInfo.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/BuiltinCommandInfo.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
@@ -17,6 +17,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+
package org.jnode.shell;
import org.jnode.shell.syntax.ArgumentBundle;
Modified: trunk/shell/src/shell/org/jnode/shell/Command.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/Command.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/Command.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandInfo.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
@@ -17,6 +17,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+
package org.jnode.shell;
public interface CommandRunnable extends Runnable {
Modified: trunk/shell/src/shell/org/jnode/shell/CommandRunner.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
@@ -17,6 +17,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+
package org.jnode.shell;
import java.io.IOException;
Modified: trunk/shell/src/shell/org/jnode/shell/CommandThread.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandThread.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandThread.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java 2010-01-03 13:32:10 UTC (rev 5713)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2009 JNode.org
+ * Copyright (C) 2003-2010 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/Completable.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/Completable.java 2010-01-03 13:13:59 UTC (rev 5712)
+++ trunk/shell/src/shell/org/jnode/shell/Completable.java 2010-01-03 13:32:10 UTC (rev 5...
[truncated message content] |
|
From: <ls...@us...> - 2013-02-17 21:43:24
|
Revision: 5960
http://jnode.svn.sourceforge.net/jnode/?rev=5960&view=rev
Author: lsantha
Date: 2013-02-17 21:43:09 +0000 (Sun, 17 Feb 2013)
Log Message:
-----------
Updated headers.
Modified Paths:
--------------
trunk/shell/src/emu/org/jnode/emu/DeviceManager.java
trunk/shell/src/emu/org/jnode/emu/Emu.java
trunk/shell/src/emu/org/jnode/emu/EmuException.java
trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java
trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java
trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/BuiltinCommandInfo.java
trunk/shell/src/shell/org/jnode/shell/Command.java
trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java
trunk/shell/src/shell/org/jnode/shell/CommandInfo.java
trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java
trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/CommandLine.java
trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java
trunk/shell/src/shell/org/jnode/shell/CommandRunner.java
trunk/shell/src/shell/org/jnode/shell/CommandShell.java
trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java
trunk/shell/src/shell/org/jnode/shell/CommandThread.java
trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java
trunk/shell/src/shell/org/jnode/shell/Completable.java
trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java
trunk/shell/src/shell/org/jnode/shell/NoTokensAvailableException.java
trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java
trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java
trunk/shell/src/shell/org/jnode/shell/Shell.java
trunk/shell/src/shell/org/jnode/shell/ShellControlException.java
trunk/shell/src/shell/org/jnode/shell/ShellException.java
trunk/shell/src/shell/org/jnode/shell/ShellFailureException.java
trunk/shell/src/shell/org/jnode/shell/ShellInvocationException.java
trunk/shell/src/shell/org/jnode/shell/ShellManager.java
trunk/shell/src/shell/org/jnode/shell/ShellSyntaxException.java
trunk/shell/src/shell/org/jnode/shell/ShellUtils.java
trunk/shell/src/shell/org/jnode/shell/SimpleCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/SymbolSource.java
trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/ThreadExitListener.java
trunk/shell/src/shell/org/jnode/shell/alias/AliasManager.java
trunk/shell/src/shell/org/jnode/shell/alias/NoSuchAliasException.java
trunk/shell/src/shell/org/jnode/shell/alias/def/DefaultAliasManager.java
trunk/shell/src/shell/org/jnode/shell/bjorne/AliasBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/AssignmentArgument.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneAliasDefinitionArgument.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneAliasNameArgument.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneArithmeticEvaluator.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltinCommandInfo.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompletable.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompleter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjornePipeline.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneShellPlugin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneSubshellRunner.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BreakBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CaseItemNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CharIterator.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ColonBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ContinueBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ExportBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ReadBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ReadonlyBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/RedirectionNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ReturnBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SetBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SetFlagArgument.java
trunk/shell/src/shell/org/jnode/shell/bjorne/ShiftBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java
trunk/shell/src/shell/org/jnode/shell/bjorne/SourceBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/UnaliasBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/UnsetBuiltin.java
trunk/shell/src/shell/org/jnode/shell/bjorne/VariableNameArgument.java
trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java
trunk/shell/src/shell/org/jnode/shell/command/bsh/BshCommand.java
trunk/shell/src/shell/org/jnode/shell/command/driver/DeviceCommand.java
trunk/shell/src/shell/org/jnode/shell/command/driver/console/ClearConsoleCommand.java
trunk/shell/src/shell/org/jnode/shell/command/driver/console/ConsoleCommand.java
trunk/shell/src/shell/org/jnode/shell/command/driver/system/acpi/AcpiCommand.java
trunk/shell/src/shell/org/jnode/shell/command/driver/system/bus/SMBusCommand.java
trunk/shell/src/shell/org/jnode/shell/command/test/SuiteCommand.java
trunk/shell/src/shell/org/jnode/shell/command/test/TestCommand.java
trunk/shell/src/shell/org/jnode/shell/def/DefaultShellManager.java
trunk/shell/src/shell/org/jnode/shell/def/ShellPlugin.java
trunk/shell/src/shell/org/jnode/shell/help/CommandLineElement.java
trunk/shell/src/shell/org/jnode/shell/help/CompletionException.java
trunk/shell/src/shell/org/jnode/shell/help/EnhancedHelp.java
trunk/shell/src/shell/org/jnode/shell/help/Help.java
trunk/shell/src/shell/org/jnode/shell/help/HelpException.java
trunk/shell/src/shell/org/jnode/shell/help/HelpFactory.java
trunk/shell/src/shell/org/jnode/shell/help/def/DefaultHelpFactory.java
trunk/shell/src/shell/org/jnode/shell/help/def/NewSyntaxHelp.java
trunk/shell/src/shell/org/jnode/shell/help/def/SystemHelpPlugin.java
trunk/shell/src/shell/org/jnode/shell/help/def/TextHelpBase.java
trunk/shell/src/shell/org/jnode/shell/io/BaseCommandIO.java
trunk/shell/src/shell/org/jnode/shell/io/CommandIO.java
trunk/shell/src/shell/org/jnode/shell/io/CommandIOException.java
trunk/shell/src/shell/org/jnode/shell/io/CommandIOHolder.java
trunk/shell/src/shell/org/jnode/shell/io/CommandIOMarker.java
trunk/shell/src/shell/org/jnode/shell/io/CommandInput.java
trunk/shell/src/shell/org/jnode/shell/io/CommandInputOutput.java
trunk/shell/src/shell/org/jnode/shell/io/CommandOutput.java
trunk/shell/src/shell/org/jnode/shell/io/FanoutWriter.java
trunk/shell/src/shell/org/jnode/shell/io/NullInputStream.java
trunk/shell/src/shell/org/jnode/shell/io/NullOutputStream.java
trunk/shell/src/shell/org/jnode/shell/io/Pipeline.java
trunk/shell/src/shell/org/jnode/shell/io/PipelineInputStream.java
trunk/shell/src/shell/org/jnode/shell/io/PipelineOutputStream.java
trunk/shell/src/shell/org/jnode/shell/io/ShellConsoleReader.java
trunk/shell/src/shell/org/jnode/shell/io/ShellConsoleWriter.java
trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandLauncher.java
trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandThreadImpl.java
trunk/shell/src/shell/org/jnode/shell/isolate/IsolateSocket.java
trunk/shell/src/shell/org/jnode/shell/isolate/IsolateSocketImpl.java
trunk/shell/src/shell/org/jnode/shell/proclet/AbstractProxyPrintStream.java
trunk/shell/src/shell/org/jnode/shell/proclet/Proclet.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletCommandInvoker.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletException.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletIOContext.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyInputStream.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyPrintStream.java
trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyStream.java
trunk/shell/src/shell/org/jnode/shell/syntax/AliasArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/AlternativesSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/Argument.java
trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentBundle.java
trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentSpecLoader.java
trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/ClassNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/CommandSyntaxException.java
trunk/shell/src/shell/org/jnode/shell/syntax/CountryArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/DefaultSyntaxManager.java
trunk/shell/src/shell/org/jnode/shell/syntax/DeviceArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/EmptySyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/EnumArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/FlagArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/GroupSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/HostNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/IntegerArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/KeyboardLayoutArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/LanguageArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLevelArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLoggerArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/LongArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/MappedArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuAlternation.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuBackReference.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuParser.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuPreset.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuSequence.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuSymbol.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/OptionSetSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/OptionSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/OptionalSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/PluginArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/PluginSyntaxSpecAdapter.java
trunk/shell/src/shell/org/jnode/shell/syntax/PortNumberArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/PowersetSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/PropertyNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/RepeatSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/SequenceSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/SharedStack.java
trunk/shell/src/shell/org/jnode/shell/syntax/ShellPropertyNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/StringArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/SymbolSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/Syntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxArgumentMissingException.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxBundle.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxFailureException.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxManager.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxMultiplicityException.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxSpecAdapter.java
trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxSpecLoader.java
trunk/shell/src/shell/org/jnode/shell/syntax/SystemSyntaxPlugin.java
trunk/shell/src/shell/org/jnode/shell/syntax/ThreadNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/VerbSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/XMLSyntaxSpecAdapter.java
trunk/shell/src/test/org/jnode/test/shell/AllTests.java
trunk/shell/src/test/org/jnode/test/shell/Cassowary.java
trunk/shell/src/test/org/jnode/test/shell/CompletionHelper.java
trunk/shell/src/test/org/jnode/test/shell/CompletionInfoTest.java
trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java
trunk/shell/src/test/org/jnode/test/shell/DefaultSyntaxCompletionTest.java
trunk/shell/src/test/org/jnode/test/shell/DeviceManager.java
trunk/shell/src/test/org/jnode/test/shell/MyAliasCommand.java
trunk/shell/src/test/org/jnode/test/shell/MyCompileCommand.java
trunk/shell/src/test/org/jnode/test/shell/MyCpuIDCommand.java
trunk/shell/src/test/org/jnode/test/shell/MyDuhCommand.java
trunk/shell/src/test/org/jnode/test/shell/MyEchoCommand.java
trunk/shell/src/test/org/jnode/test/shell/PathnamePatternTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneArithmeticEvaluatorTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTest.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTest.java
trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java
trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java
trunk/shell/src/test/org/jnode/test/shell/harness/DummyPseudoPlugin.java
trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java
trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java
trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerException.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSetSpecification.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestsAbandonedException.java
trunk/shell/src/test/org/jnode/test/shell/harness/TextContent.java
trunk/shell/src/test/org/jnode/test/shell/help/DefaultHelpTest.java
trunk/shell/src/test/org/jnode/test/shell/io/PipelineTest.java
trunk/shell/src/test/org/jnode/test/shell/io/ReaderInputStreamTest.java
trunk/shell/src/test/org/jnode/test/shell/io/WriterOutputStreamTest.java
trunk/shell/src/test/org/jnode/test/shell/proclet/ProcletStreamTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/AllTests.java
trunk/shell/src/test/org/jnode/test/shell/syntax/AlternativesSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/ArgumentBundleTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/ArgumentMultiplicityTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/ArgumentTypesTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/CommandLineTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/DefaultTokenizerTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/MuParserTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/MuParserTest2.java
trunk/shell/src/test/org/jnode/test/shell/syntax/MuSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/OptionSetSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/OptionSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/PowersetSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/RepeatSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/SequenceSyntaxTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/TestAliasManager.java
trunk/shell/src/test/org/jnode/test/shell/syntax/TestShell.java
trunk/shell/src/test/org/jnode/test/shell/syntax/TestSyntaxManager.java
Modified: trunk/shell/src/emu/org/jnode/emu/DeviceManager.java
===================================================================
--- trunk/shell/src/emu/org/jnode/emu/DeviceManager.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/emu/org/jnode/emu/DeviceManager.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/emu/org/jnode/emu/Emu.java
===================================================================
--- trunk/shell/src/emu/org/jnode/emu/Emu.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/emu/org/jnode/emu/Emu.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/emu/org/jnode/emu/EmuException.java
===================================================================
--- trunk/shell/src/emu/org/jnode/emu/EmuException.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/emu/org/jnode/emu/EmuException.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/BuiltinCommandInfo.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/BuiltinCommandInfo.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/BuiltinCommandInfo.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/Command.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/Command.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/Command.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandInfo.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandRunnable.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandRunner.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShellReader.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandThread.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandThread.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandThread.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java 2013-02-17 21:43:09 UTC (rev 5960)
@@ -1,7 +1,7 @@
/*
- * $Id: header.txt 5714 2010-01-03 13:33:07Z lsantha $
+ * $Id$
*
- * Copyright (C) 2003-2012 JNode.org
+ * Copyright (C) 2003-2013 JNode.org
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Modified: trunk/shell/src/shell/org/jnode/shell/Completable.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/Completable.java 2013-02-17 21:33:21 UTC (rev 5959)
+++ trunk/shell/src/shell/org/jnode/shell/C...
[truncated message content] |