From: <cr...@us...> - 2008-08-16 14:25:18
|
Revision: 4452 http://jnode.svn.sourceforge.net/jnode/?rev=4452&view=rev Author: crawley Date: 2008-08-16 14:25:15 +0000 (Sat, 16 Aug 2008) Log Message: ----------- Add annotations for uses of deprecated help.argument classes Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/CommandLine.java trunk/shell/src/shell/org/jnode/shell/help/Syntax.java trunk/shell/src/test/org/jnode/test/shell/MyCatCommand.java trunk/shell/src/test/org/jnode/test/shell/MyDirCommand.java Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2008-08-16 14:23:17 UTC (rev 4451) +++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2008-08-16 14:25:15 UTC (rev 4452) @@ -43,6 +43,7 @@ * * @author cr...@jn... */ +@SuppressWarnings("deprecation") public class CommandLine implements Completable, Iterable<String> { public static final Closeable DEFAULT_STDIN = new StreamMarker("STDIN"); @@ -92,6 +93,7 @@ private static final String[] NO_ARGS = new String[0]; private static final Token[] NO_TOKENS = new Token[0]; + @SuppressWarnings("deprecation") private final Help.Info defaultInfo = new Help.Info("file", "default parameter for command line completion", new Parameter( Modified: trunk/shell/src/shell/org/jnode/shell/help/Syntax.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/Syntax.java 2008-08-16 14:23:17 UTC (rev 4451) +++ trunk/shell/src/shell/org/jnode/shell/help/Syntax.java 2008-08-16 14:25:15 UTC (rev 4452) @@ -35,6 +35,7 @@ * @author qades * @author cr...@jn... */ +@SuppressWarnings("deprecation") public class Syntax { public static final boolean DEBUG = false; Modified: trunk/shell/src/test/org/jnode/test/shell/MyCatCommand.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/MyCatCommand.java 2008-08-16 14:23:17 UTC (rev 4451) +++ trunk/shell/src/test/org/jnode/test/shell/MyCatCommand.java 2008-08-16 14:25:15 UTC (rev 4452) @@ -34,6 +34,7 @@ /** * Cut down test class */ +@SuppressWarnings("deprecation") public class MyCatCommand extends AbstractCommand { static final FileArgument ARG_FILE = new FileArgument("file", Modified: trunk/shell/src/test/org/jnode/test/shell/MyDirCommand.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/MyDirCommand.java 2008-08-16 14:23:17 UTC (rev 4451) +++ trunk/shell/src/test/org/jnode/test/shell/MyDirCommand.java 2008-08-16 14:25:15 UTC (rev 4452) @@ -32,6 +32,7 @@ /** * Cut down test class ... dir done the old way */ +@SuppressWarnings("deprecation") public class MyDirCommand extends AbstractCommand { static final FileArgument ARG_PATH = new FileArgument("path", "the path to list contents of"); public static Help.Info HELP_INFO = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-09-03 10:43:57
|
Revision: 4535 http://jnode.svn.sourceforge.net/jnode/?rev=4535&view=rev Author: crawley Date: 2008-09-03 10:43:53 +0000 (Wed, 03 Sep 2008) Log Message: ----------- Bug fixes + extended unit tests for ReaderInputStream Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/io/ReaderInputStream.java trunk/shell/src/test/org/jnode/test/shell/io/ReaderInputStreamTest.java Modified: trunk/shell/src/shell/org/jnode/shell/io/ReaderInputStream.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/io/ReaderInputStream.java 2008-09-03 10:42:12 UTC (rev 4534) +++ trunk/shell/src/shell/org/jnode/shell/io/ReaderInputStream.java 2008-09-03 10:43:53 UTC (rev 4535) @@ -1,3 +1,23 @@ +/* + * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * + * JNode.org + * Copyright (C) 2007 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.io; import java.io.IOException; @@ -27,7 +47,7 @@ @Override public synchronized int read() throws IOException { if (bytes.remaining() == 0) { - if (!fillBuffer(true)) { + if (fillBuffer(true) == -1) { return -1; } } @@ -42,19 +62,19 @@ // This implementation is simple-minded. I'm sure we could recode it to avoid // the 'bytes.get' copying step if we thought about it. int count = 0; - while (count < len) { + do { if (bytes.remaining() == 0) { - if (!fillBuffer(count == 0)) { - return count == 0 ? -1 : count; + int nosRead = fillBuffer(count == 0); + if (nosRead <= 0) { + return count > 0 ? count : -1; } } - int copied = Math.min(bytes.remaining(), len); - bytes.get(b, off, copied); - System.err.println("Copied " + copied); - count += copied; - len -= copied; - off += copied; - } + int toCopy = Math.min(bytes.remaining(), len); + bytes.get(b, off, toCopy); + count += toCopy; + len -= toCopy; + off += toCopy; + } while (count < len); return count; } @@ -69,33 +89,39 @@ * would have blocked or because it returned <code>-1</code>. * * @param wait if <code>true</code> allow the reader to block. - * @return <code>true</code> if we've added some data to 'bytes'. + * @return the number of bytes added; <code>-1</code> if none were added + * and the reader is at the EOF. * @throws IOException */ - private boolean fillBuffer(boolean wait) throws IOException { + private int fillBuffer(boolean wait) throws IOException { bytes.clear(); // The loop is necessary because the way that the encoder has to deal - // with UTF-16 surrogate pairs. If the one and only character returned - // by the reader is the first char of a surrogate pair, the encoder won't - // (can't) put anything into the 'bytes' buffer. So if 'wait' is true, - // we must go around a second time to get the second character of the - // surrogate pair. + // with UTF-16 surrogate pairs. + CoderResult cr = null; + int count; do { - CoderResult cr; - if (chars.remaining() == 0) { - chars.clear(); - if (!reader.ready() && !wait) { - bytes.flip(); - return false; + if (chars.remaining() == 0 || cr == CoderResult.UNDERFLOW) { + if (chars.remaining() == 0) { + if (!reader.ready() && !wait) { + bytes.flip(); + return 0; + } + chars.clear(); + } else { + char[] tmp = new char[chars.remaining()]; + chars.get(tmp); + chars.clear(); + chars.put(tmp); } if (reader.read(chars) == -1) { - System.err.println("Reached EOF"); - bytes.flip(); + chars.flip(); cr = encoder.encode(chars, bytes, true); if (cr.isError()) { cr.throwException(); } - return bytes.remaining() > 0; + count = bytes.position(); + bytes.flip(); + return count > 0 ? count : -1; } chars.flip(); } @@ -103,8 +129,9 @@ if (cr.isError()) { cr.throwException(); } - } while (wait && bytes.position() == 0); + count = bytes.position(); + } while (wait && count == 0); bytes.flip(); - return true; + return count; } } Modified: trunk/shell/src/test/org/jnode/test/shell/io/ReaderInputStreamTest.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/io/ReaderInputStreamTest.java 2008-09-03 10:42:12 UTC (rev 4534) +++ trunk/shell/src/test/org/jnode/test/shell/io/ReaderInputStreamTest.java 2008-09-03 10:43:53 UTC (rev 4535) @@ -1,9 +1,31 @@ +/* + * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * + * JNode.org + * Copyright (C) 2007 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.io; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; +import java.nio.charset.MalformedInputException; import java.nio.charset.UnmappableCharacterException; import org.jnode.shell.io.ReaderInputStream; @@ -93,7 +115,7 @@ assertEquals((byte) i, buffer[i]); } } - + public void testBadLatin1All() throws Exception { char[] chars = new char[257]; for (int i = 0; i < 257; i++) { @@ -110,4 +132,161 @@ // expected } } + + public void testUnicode() throws Exception { + char[] chars = new char[1024]; + for (int i = 0; i < 1024; i++) { + chars[i] = (char) i; + } + final String LINE = new String(chars); + Reader r = new StringReader(LINE); + ReaderInputStream ris = new ReaderInputStream(r, "UTF-8"); + InputStreamReader isr = new InputStreamReader(ris); + char[] buffer = new char[1024]; + isr.read(buffer); + for (int i = 0; i < 1024; i++) { + assertEquals(chars[i], buffer[i]); + } + } + + public void testUnicode2() throws Exception { + char[] chars = new char[]{'\ud800', '\udc00'}; + final String LINE = new String(chars); + Reader r = new StringReader(LINE); + ReaderInputStream ris = new ReaderInputStream(r, "UTF-8"); + InputStreamReader isr = new InputStreamReader(ris); + assertEquals(chars[0], isr.read()); + assertEquals(chars[1], isr.read()); + } + + public void testBadUnicode() throws Exception { + char[] chars = new char[]{'\ud800'}; + final String LINE = new String(chars); + Reader r = new StringReader(LINE); + ReaderInputStream ris = new ReaderInputStream(r, "UTF-8"); + InputStreamReader isr = new InputStreamReader(ris); + try { + isr.read(); + fail("No exception raised"); + } catch (MalformedInputException ex) { + // expected + } + } + + public void testBadUnicode2() throws Exception { + char[] chars = new char[]{'a', '\ud800'}; + final String LINE = new String(chars); + Reader r = new StringReader(LINE); + ReaderInputStream ris = new ReaderInputStream(r, "UTF-8"); + InputStreamReader isr = new InputStreamReader(ris); + assertEquals(chars[0], isr.read()); + try { + isr.read(); + fail("No exception raised"); + } catch (MalformedInputException ex) { + // expected + } + } + + public void testBadUnicode3() throws Exception { + char[] chars = new char[]{'\udc00'}; + final String LINE = new String(chars); + Reader r = new StringReader(LINE); + ReaderInputStream ris = new ReaderInputStream(r, "UTF-8"); + InputStreamReader isr = new InputStreamReader(ris); + try { + isr.read(); + fail("No exception raised"); + } catch (MalformedInputException ex) { + // expected + } + } + + public void testUnicode3() throws Exception { + char[] chars = new char[]{'\ud800', '\udc00'}; + final String LINE = new String(chars); + Reader r = new OneCharAtATimeReader(new StringReader(LINE)); + ReaderInputStream ris = new ReaderInputStream(r, "UTF-8"); + InputStreamReader isr = new InputStreamReader(ris); + assertEquals(chars[0], isr.read()); + assertEquals(chars[1], isr.read()); + } + + public void testBadUnicode4() throws Exception { + char[] chars = new char[]{'\ud800'}; + final String LINE = new String(chars); + Reader r = new OneCharAtATimeReader(new StringReader(LINE)); + ReaderInputStream ris = new ReaderInputStream(r, "UTF-8"); + InputStreamReader isr = new InputStreamReader(ris); + try { + isr.read(); + fail("No exception raised"); + } catch (MalformedInputException ex) { + // expected + } + } + + public void testBadUnicode5() throws Exception { + char[] chars = new char[]{'a', '\ud800'}; + final String LINE = new String(chars); + Reader r = new OneCharAtATimeReader(new StringReader(LINE)); + ReaderInputStream ris = new ReaderInputStream(r, "UTF-8"); + InputStreamReader isr = new InputStreamReader(ris); + assertEquals(chars[0], isr.read()); + try { + isr.read(); + fail("No exception raised"); + } catch (MalformedInputException ex) { + // expected + } + } + + public void testBadUnicode6() throws Exception { + char[] chars = new char[]{'\udc00'}; + final String LINE = new String(chars); + Reader r = new OneCharAtATimeReader(new StringReader(LINE)); + ReaderInputStream ris = new ReaderInputStream(r, "UTF-8"); + InputStreamReader isr = new InputStreamReader(ris); + try { + isr.read(); + fail("No exception raised"); + } catch (MalformedInputException ex) { + // expected + } + } + + /** + * This wrapper class delivers characters from a Reader one at a time, no matter + * what the client asks for. + */ + private class OneCharAtATimeReader extends Reader { + + private Reader reader; + + public OneCharAtATimeReader(Reader reader) { + this.reader = reader; + } + + @Override + public void close() throws IOException { + this.reader.close(); + } + + @Override + public int read(char[] cbuf, int off, int len) throws IOException { + if (off < 0 || off > cbuf.length || len < 0 || off + len > cbuf.length || off + len < 0) { + throw new IndexOutOfBoundsException(); + } + if (len == 0) { + return 0; + } + int ch = reader.read(); + if (ch == -1) { + return -1; + } else { + cbuf[off] = (char) ch; + return 1; + } + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-09-04 14:09:44
|
Revision: 4540 http://jnode.svn.sourceforge.net/jnode/?rev=4540&view=rev Author: crawley Date: 2008-09-04 14:09:40 +0000 (Thu, 04 Sep 2008) Log Message: ----------- Bug fixes for WriterOutputStream + unit tests Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/io/WriterOutputStream.java Added Paths: ----------- trunk/shell/src/test/org/jnode/test/shell/io/WriterOutputStreamTest.java Modified: trunk/shell/src/shell/org/jnode/shell/io/WriterOutputStream.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/io/WriterOutputStream.java 2008-09-03 23:43:55 UTC (rev 4539) +++ trunk/shell/src/shell/org/jnode/shell/io/WriterOutputStream.java 2008-09-04 14:09:40 UTC (rev 4540) @@ -7,12 +7,13 @@ import java.nio.CharBuffer; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; +import java.nio.charset.CoderResult; public class WriterOutputStream extends OutputStream { // TODO deal with decoder errors. private ByteBuffer bytes = ByteBuffer.allocate(2048); - private CharBuffer chars = CharBuffer.allocate(1024); + private CharBuffer chars = CharBuffer.allocate(2048); private Writer writer; private CharsetDecoder decoder; @@ -20,24 +21,53 @@ public WriterOutputStream(Writer writer, String encoding) { this.writer = writer; this.decoder = Charset.forName(encoding).newDecoder(); + bytes.clear(); + chars.clear(); } @Override public void write(int b) throws IOException { bytes.put((byte) b); if (bytes.remaining() == 0) { - decoder.decode(bytes, chars, false); - flush(); + flush(false); } } @Override public void flush() throws IOException { - if (chars.position() > 0) { - int len = chars.position(); - int pos = chars.arrayOffset(); - writer.write(chars.array(), pos, len); + flush(false); + } + + @Override + public void close() throws IOException { + flush(true); + writer.close(); + } + + private int flush(boolean all) throws IOException { + if (bytes.position() > 0) { + bytes.flip(); chars.clear(); + CoderResult cr = decoder.decode(bytes, chars, all); + int count = chars.position(); + if (count > 0) { + int pos = chars.arrayOffset(); + writer.write(chars.array(), pos, count); + } + if (cr.isError() || (all && cr == CoderResult.UNDERFLOW)) { + cr.throwException(); + } + if (bytes.remaining() > 0) { + byte[] tmp = new byte[bytes.remaining()]; + bytes.get(tmp); + bytes.clear(); + bytes.put(tmp); + } else { + bytes.clear(); + } + return count; + } else { + return 0; } } @@ -47,13 +77,13 @@ throw new IndexOutOfBoundsException(); } while (len > 0) { - int pos = bytes.position(); - bytes.put(b, off, len); - int count = bytes.position() - pos; - off += count; - len -= count; - decoder.decode(bytes, chars, false); - flush(); + int toWrite = Math.min(len, bytes.remaining()); + bytes.put(b, off, toWrite); + off += toWrite; + len -= toWrite; + if (bytes.remaining() == 0) { + flush(false); + } } } Added: trunk/shell/src/test/org/jnode/test/shell/io/WriterOutputStreamTest.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/io/WriterOutputStreamTest.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/io/WriterOutputStreamTest.java 2008-09-04 14:09:40 UTC (rev 4540) @@ -0,0 +1,153 @@ +/* + * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * + * JNode.org + * Copyright (C) 2007 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.io; + +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.nio.charset.MalformedInputException; +import java.nio.charset.UnmappableCharacterException; + +import junit.framework.TestCase; + +import org.jnode.shell.io.ReaderInputStream; +import org.jnode.shell.io.WriterOutputStream; + +public class WriterOutputStreamTest extends TestCase { + + public void testEmpty() throws Exception { + String LINE = ""; + StringWriter sw = new StringWriter(); + WriterOutputStream wos = new WriterOutputStream(sw, "UTF-8"); + byte[] buffer = LINE.getBytes(); + wos.write(buffer); + wos.flush(); + assertEquals(LINE, sw.getBuffer().toString()); + } + + public void testLine() throws Exception { + String LINE = "The quick brown fox jumped over the lazy doc"; + StringWriter sw = new StringWriter(); + WriterOutputStream wos = new WriterOutputStream(sw, "UTF-8"); + byte[] buffer = LINE.getBytes(); + wos.write(buffer); + wos.flush(); + assertEquals(LINE, sw.getBuffer().toString()); + } + + public void testByteAtATime() throws Exception { + String LINE = "The quick brown fox jumped over the lazy doc"; + StringWriter sw = new StringWriter(); + WriterOutputStream wos = new WriterOutputStream(sw, "UTF-8"); + byte[] buffer = LINE.getBytes(); + for (byte b : buffer) { + wos.write(b); + } + wos.flush(); + assertEquals(LINE, sw.getBuffer().toString()); + } + + public void testByteAtATimeWithFlushes() throws Exception { + String LINE = "The quick brown fox jumped over the lazy doc"; + StringWriter sw = new StringWriter(); + WriterOutputStream wos = new WriterOutputStream(sw, "UTF-8"); + byte[] buffer = LINE.getBytes(); + for (int i = 0; i < buffer.length; i++) { + wos.write(buffer[i]); + wos.flush(); + assertEquals(LINE.charAt(i), sw.getBuffer().charAt(i)); + } + assertEquals(LINE, sw.getBuffer().toString()); + } + + public void testUnicode() throws Exception { + char[] chars = new char[8192]; + for (int i = 0; i < chars.length; i++) { + chars[i] = (char) i; + } + byte[] buffer = new String(chars).getBytes(); + StringWriter sw = new StringWriter(); + WriterOutputStream wos = new WriterOutputStream(sw, "UTF-8"); + wos.write(buffer); + wos.flush(); + StringBuffer sb = sw.getBuffer(); + assertEquals(chars.length, sb.length()); + for (int i = 0; i < chars.length; i++) { + assertEquals(chars[i], sb.charAt(i)); + } + } + + public void testBadUnicode() throws Exception { + byte[] BAD = new byte[] {(byte) 0x80}; + StringWriter sw = new StringWriter(); + WriterOutputStream wos = new WriterOutputStream(sw, "UTF-8"); + try { + wos.write(BAD); + wos.flush(); + fail("no exception thrown"); + } catch (MalformedInputException ex) { + // expected + } + } + + public void testBadUnicode2() throws Exception { + byte[] BAD = new byte[] {(byte) 'h', (byte) 'i', (byte) 0x80}; + StringWriter sw = new StringWriter(); + WriterOutputStream wos = new WriterOutputStream(sw, "UTF-8"); + try { + wos.write(BAD); + wos.flush(); + fail("no exception thrown"); + } catch (MalformedInputException ex) { + // expected + assertEquals("hi", sw.getBuffer().toString()); + } + } + + public void testBadUnicode3() throws Exception { + byte[] BAD = new byte[] {(byte) 'h', (byte) 'i', (byte) 0xc2, (byte) 0x00}; + StringWriter sw = new StringWriter(); + WriterOutputStream wos = new WriterOutputStream(sw, "UTF-8"); + try { + wos.write(BAD); + wos.flush(); + fail("no exception thrown"); + } catch (MalformedInputException ex) { + // expected + assertEquals("hi", sw.getBuffer().toString()); + } + } + + public void testBadUnicode4() throws Exception { + byte[] BAD = new byte[] {(byte) 'h', (byte) 'i', (byte) 0xc2}; + StringWriter sw = new StringWriter(); + WriterOutputStream wos = new WriterOutputStream(sw, "UTF-8"); + wos.write(BAD); + wos.flush(); + try { + wos.close(); + fail("no exception thrown"); + } catch (MalformedInputException ex) { + // expected + assertEquals("hi", sw.getBuffer().toString()); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-11-04 11:04:56
|
Revision: 4666 http://jnode.svn.sourceforge.net/jnode/?rev=4666&view=rev Author: crawley Date: 2008-11-04 11:04:49 +0000 (Tue, 04 Nov 2008) Log Message: ----------- Change shell's command line tokenizer to throw a more appropriate exception when it sees an incomplete '\' escape sequence. 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/test/org/jnode/test/shell/syntax/DefaultTokenizerTest.java Modified: trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2008-11-03 14:22:31 UTC (rev 4665) +++ trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2008-11-04 11:04:49 UTC (rev 4666) @@ -53,10 +53,9 @@ * @param partial a input to the interpreter. * @return the CommandLine represent the fragment of the supplied command * input to be completed. - * @throws ShellException + * @throws ShellException */ - Completable parsePartial(CommandShell shell, String partial) - throws ShellSyntaxException; + Completable parsePartial(CommandShell shell, String partial) throws ShellException; /** * Get the interpreter's name Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2008-11-03 14:22:31 UTC (rev 4665) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2008-11-04 11:04:49 UTC (rev 4666) @@ -649,7 +649,7 @@ } public Completable parseCommandLine(String cmdLineStr) - throws ShellSyntaxException { + throws ShellException { return interpreter.parsePartial(this, cmdLineStr); } @@ -678,7 +678,7 @@ if (cl != null) { cl.complete(completion, this); } - } catch (ShellSyntaxException ex) { + } catch (ShellException ex) { outPW.println(); // next line errPW.println("Cannot parse: " + ex.getMessage()); stackTrace(ex); Modified: trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2008-11-03 14:22:31 UTC (rev 4665) +++ trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2008-11-04 11:04:49 UTC (rev 4666) @@ -110,8 +110,7 @@ } } - public Completable parsePartial(CommandShell shell, String line) - throws ShellSyntaxException { + public Completable parsePartial(CommandShell shell, String line) throws ShellException { Tokenizer tokenizer = new Tokenizer(line); if (!tokenizer.hasNext()) { return new CommandLine("", null); @@ -211,12 +210,13 @@ * * @param line the input String. * @param flags flags controlling the tokenization. + * @throws ShellException */ - public Tokenizer(String line, int flags) { + public Tokenizer(String line, int flags) throws ShellSyntaxException { tokenize(line, flags); } - public Tokenizer(String line) { + public Tokenizer(String line) throws ShellSyntaxException { this(line, 0); } @@ -242,7 +242,7 @@ return tokens.get(pos++); } - private void tokenize(String s, int flags) throws IllegalArgumentException { + private void tokenize(String s, int flags) throws ShellSyntaxException { int pos = 0; while (true) { @@ -271,7 +271,7 @@ switch (currentChar) { case ESCAPE_CHAR: if (pos >= s.length()) { - throw new IllegalArgumentException( + throw new ShellSyntaxException( "escape char ('\\') not followed by a character"); } char ch; Modified: trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2008-11-03 14:22:31 UTC (rev 4665) +++ trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2008-11-04 11:04:49 UTC (rev 4666) @@ -78,7 +78,7 @@ } public Completable parsePartial(CommandShell shell, String line) - throws ShellSyntaxException { + throws ShellException { Tokenizer tokenizer = new Tokenizer(line, REDIRECTS_FLAG); List<CommandDescriptor> commands = new LinkedList<CommandDescriptor>(); return parse(tokenizer, commands, true); Modified: trunk/shell/src/test/org/jnode/test/shell/syntax/DefaultTokenizerTest.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/syntax/DefaultTokenizerTest.java 2008-11-03 14:22:31 UTC (rev 4665) +++ trunk/shell/src/test/org/jnode/test/shell/syntax/DefaultTokenizerTest.java 2008-11-04 11:04:49 UTC (rev 4666) @@ -25,34 +25,35 @@ import junit.framework.TestCase; import org.jnode.shell.CommandLine; import org.jnode.shell.DefaultInterpreter; +import org.jnode.shell.ShellException; import org.jnode.shell.SymbolSource; public class DefaultTokenizerTest extends TestCase { // Expose methods for testing. private class MyDefaultInterpreter extends DefaultInterpreter { - DefaultInterpreter.Tokenizer makeTokenizer(String line) { + DefaultInterpreter.Tokenizer makeTokenizer(String line) throws ShellException { return new DefaultInterpreter.Tokenizer(line); } - DefaultInterpreter.Tokenizer makeTokenizer(String line, int flags) { + DefaultInterpreter.Tokenizer makeTokenizer(String line, int flags) throws ShellException { return new DefaultInterpreter.Tokenizer(line, flags); } } - public void testTokenizerEmpty() { + public void testTokenizerEmpty() throws ShellException { SymbolSource<CommandLine.Token> t = new MyDefaultInterpreter().makeTokenizer(""); assertEquals(false, t.hasNext()); assertEquals(false, t.whitespaceAfterLast()); } - public void testTokenizerSpaces() { + public void testTokenizerSpaces() throws ShellException { SymbolSource<CommandLine.Token> t = new MyDefaultInterpreter().makeTokenizer(" "); assertEquals(false, t.hasNext()); assertEquals(true, t.whitespaceAfterLast()); } - public void testTokenizerSimple() { + public void testTokenizerSimple() throws ShellException{ SymbolSource<CommandLine.Token> t = new MyDefaultInterpreter().makeTokenizer("a b c"); assertEquals(true, t.hasNext()); assertEquals(false, t.whitespaceAfterLast()); @@ -97,7 +98,7 @@ } } - public void testTokenizerQuotes() { + public void testTokenizerQuotes() throws ShellException { SymbolSource<CommandLine.Token> t = new MyDefaultInterpreter().makeTokenizer("'a' \"b c\""); assertEquals(true, t.hasNext()); assertEquals(false, t.whitespaceAfterLast()); @@ -112,7 +113,7 @@ assertEquals(false, t.hasNext()); } - public void testTokenizerBackslashes() { + public void testTokenizerBackslashes() throws ShellException { SymbolSource<CommandLine.Token> t = new MyDefaultInterpreter().makeTokenizer("\\'a b\\ c\\\""); assertEquals(true, t.hasNext()); assertEquals(false, t.whitespaceAfterLast()); @@ -127,7 +128,7 @@ assertEquals(false, t.hasNext()); } - public void testTokenizerBackslashes2() { + public void testTokenizerBackslashes2() throws ShellException { SymbolSource<CommandLine.Token> t = new MyDefaultInterpreter().makeTokenizer("\\\\\\n\\r\\t\\b "); assertEquals(true, t.hasNext()); assertEquals(true, t.whitespaceAfterLast()); @@ -138,7 +139,7 @@ assertEquals(false, t.hasNext()); } - public void testTokenizerRedirects() { + public void testTokenizerRedirects() throws ShellException { SymbolSource<CommandLine.Token> t = new MyDefaultInterpreter().makeTokenizer("a< >b c|d \"<\" \\< '<'", MyDefaultInterpreter.REDIRECTS_FLAG); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-01-12 14:22:22
|
Revision: 4851 http://jnode.svn.sourceforge.net/jnode/?rev=4851&view=rev Author: crawley Date: 2009-01-12 14:22:05 +0000 (Mon, 12 Jan 2009) Log Message: ----------- Tweaking some Bjorne unit tests Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java Added Paths: ----------- trunk/shell/src/test/org/jnode/test/shell/bjorne/ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java Removed Paths: ------------- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContextTests.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParserTests.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizerTests.java Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-01-12 08:03:50 UTC (rev 4850) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-01-12 14:22:05 UTC (rev 4851) @@ -251,18 +251,16 @@ } /** - * Perform expand-and-split processing on a sequence of characters. The resulting - * wordTokens are assembled into a CommandLine. This method is only used in tests - * at the moment, and probably should be removed. (It does not set token attributes - * properly ...) + * Perform expand-and-split processing on a sequence of characters. This method is only + * used in tests at the moment, and probably should be removed. (It does not set token + * attributes properly ...) * * @param text the characters to be split * @return the command line * @throws ShellException */ - public CommandLine expandAndSplit(CharSequence text) throws ShellException { - LinkedList<BjorneToken> words = split(expand(text)); - return makeCommandLine(words); + public List<BjorneToken> expandAndSplit(CharSequence text) throws ShellException { + return split(expand(text)); } private CommandLine makeCommandLine(LinkedList<BjorneToken> wordTokens) { @@ -337,7 +335,7 @@ */ public LinkedList<BjorneToken> split(CharSequence text) throws ShellException { LinkedList<BjorneToken> wordTokens = new LinkedList<BjorneToken>(); - splitAndAppend(new BjorneToken(-1, text.toString(), -1, -1), wordTokens); + splitAndAppend(new BjorneToken(BjorneToken.TOK_WORD, text.toString(), -1, -1), wordTokens); return wordTokens; } Deleted: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContextTests.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContextTests.java 2009-01-12 08:03:50 UTC (rev 4850) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContextTests.java 2009-01-12 14:22:05 UTC (rev 4851) @@ -1,133 +0,0 @@ -/* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ - * - * JNode.org - * Copyright (C) 2007-2008 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.Iterator; - -import junit.framework.TestCase; - -import org.jnode.shell.CommandLine; -import org.jnode.shell.ShellException; - -public class BjorneContextTests extends TestCase { - - public void testContext() { - new BjorneContext(null, null); - } - - public void testExpand1() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - CommandLine expansion = context.expandAndSplit(""); - checkExpansion(expansion, new String[] {}); - } - - public void testExpand2() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - CommandLine expansion = context.expandAndSplit(" "); - checkExpansion(expansion, new String[] {}); - } - - public void testExpand3() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - CommandLine expansion = context.expandAndSplit("hi"); - checkExpansion(expansion, new String[] {"hi"}); - } - - public void testExpand4() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - CommandLine expansion = context.expandAndSplit("hi there "); - checkExpansion(expansion, new String[] {"hi", "there"}); - } - - public void testExpand5() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - CommandLine expansion = context.expandAndSplit("'hi there '"); - checkExpansion(expansion, new String[] {"hi there "}); - } - - public void testExpand6() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - CommandLine expansion = context.expandAndSplit("\"hi there \" "); - checkExpansion(expansion, new String[] {"hi there "}); - } - - public void testExpand7() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - CommandLine expansion = context.expandAndSplit("hi\\ there"); - checkExpansion(expansion, new String[] {"hi there"}); - } - - public void testExpand8() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - CommandLine expansion = context.expandAndSplit("\\\"hi\\ there\\\""); - checkExpansion(expansion, new String[] {"\"hi there\""}); - } - - public void testExpand9() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - CommandLine expansion = context.expandAndSplit("$?"); - checkExpansion(expansion, new String[] {"0"}); - } - - public void testExpand10() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - context.setVariable("A", "A"); - CommandLine expansion = context.expandAndSplit("$A"); - checkExpansion(expansion, new String[] {"A"}); - } - - public void testExpand11() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - context.setVariable("A", "A"); - CommandLine expansion = context.expandAndSplit("\\$A"); - checkExpansion(expansion, new String[] {"$A"}); - } - - public void testExpand12() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - context.setVariable("A", "A"); - CommandLine expansion = context.expandAndSplit("\"$A\""); - checkExpansion(expansion, new String[] {"A"}); - } - - public void testExpand13() throws ShellException { - BjorneContext context = new BjorneContext(null, null); - context.setVariable("A", "A"); - CommandLine expansion = context.expandAndSplit("'$A'"); - checkExpansion(expansion, new String[] {"$A"}); - } - - @SuppressWarnings("deprecation") - private void checkExpansion(CommandLine expansion, String[] expected) { - int i; - Iterator<String> it = expansion.iterator(); - for (i = 0; i < expected.length; i++) { - if (it.hasNext()) { - assertEquals("incorrect expansion at word " + i, expected[i], it.next()); - } else { - fail("Too few words in expansion at word " + i + ": expecting '" + expected[i] + "'"); - } - } - if (it.hasNext()) { - fail("Too many words in expansion at word " + i + ": '" + it.next() + "'"); - } - } -} Deleted: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParserTests.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParserTests.java 2009-01-12 08:03:50 UTC (rev 4850) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParserTests.java 2009-01-12 14:22:05 UTC (rev 4851) @@ -1,138 +0,0 @@ -/* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ - * - * JNode.org - * Copyright (C) 2007-2008 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 junit.framework.TestCase; - -import org.jnode.shell.ShellException; - -public class BjorneParserTests extends TestCase { - - private static final boolean DEBUG = true; - - public void testParser() { - new BjorneParser(new BjorneTokenizer("")); - } - - public void test1() throws ShellException { - assertEquals( - "SimpleCommand{nodeType=1,command=WORD{foo},arguments=[]}", - doTest("foo")); - } - - public void test2() throws ShellException { - assertEquals( - "SimpleCommand{nodeType=1,command=WORD{ls},arguments=[WORD{-l}]}", - doTest("ls -l")); - } - - public void test3() throws ShellException { - assertEquals( - "SimpleCommand{nodeType=1," - + "redirects=[Redirect{redirectionType=60,io=IO_NUMBER{1},arg=WORD{/tmp/foo}}," - + "Redirect{redirectionType=62,arg=WORD{/tmp/bar}}]," - + "command=WORD{ls},arguments=[WORD{-l}]}", - doTest("ls -l 1< /tmp/foo > /tmp/bar")); - } - - public void test4() throws ShellException { - assertEquals( - "ListCommand{nodeType=2,flags=0x10," - + "commands=[SimpleCommand{nodeType=1,assignments=[ASSIGNMENT{FOO=BAR}]," - + "command=WORD{ls},arguments=[WORD{-l}]}," - + "SimpleCommand{nodeType=1,command=WORD{less},arguments=[]}]}", - doTest("FOO=BAR ls -l | less")); - } - - public void test5() throws ShellException { - assertEquals( - "ListCommand{nodeType=2,flags=0x10,commands=[" - + "SimpleCommand{nodeType=1,command=WORD{cat},arguments=[WORD{foo}]}," - + "ListCommand{nodeType=10,commands=[" - + "ListCommand{nodeType=2,commands=[" - + "SimpleCommand{nodeType=1,command=WORD{wc},arguments=[WORD{1}]}," - + "SimpleCommand{nodeType=1,flags=0x2,command=WORD{wc},arguments=[WORD{2}]}]}," - + "ListCommand{nodeType=2,commands=[" - + "SimpleCommand{nodeType=1,command=WORD{wc},arguments=[WORD{3}]}," - + "SimpleCommand{nodeType=1,flags=0x4,command=WORD{wc},arguments=[WORD{4}]}]}]}]}", - doTest("cat foo | ( wc 1 && wc 2 ; wc 3 || wc 4 )")); - } - - public void test6() throws ShellException { - assertEquals( - "ListCommand{nodeType=2,commands=[" - + "SimpleCommand{nodeType=1,flags=0x1,command=WORD{cat},arguments=[WORD{foo}]}," - + "SimpleCommand{nodeType=1,command=WORD{cat},arguments=[WORD{bar}]}," - + "SimpleCommand{nodeType=1,command=WORD{cat},arguments=[WORD{baz}]}]}", - doTest("cat foo & cat bar ; cat baz ;")); - } - - public void test7() throws ShellException { - assertEquals( - "LoopCommand{nodeType=3,var=NAME{i}," - + "words=[WORD{1},WORD{2},WORD{3},WORD{4},WORD{5}]," - + "body=SimpleCommand{nodeType=1,command=WORD{echo},arguments=[WORD{$i}]}}", - doTest("for i in 1 2 3 4 5 ; do echo $i ; done")); - } - - public void test7a() throws ShellException { - assertEquals( - "LoopCommand{nodeType=3,var=NAME{i}," - + "words=[WORD{1},WORD{2},WORD{3},WORD{4},WORD{5}]," - + "body=SimpleCommand{nodeType=1,command=WORD{echo},arguments=[WORD{$i}]}}", - doTest("for i in 1 2 3 4 5 ; do \n echo $i ; done")); - } - - public void test8() throws ShellException { - assertEquals( - "LoopCommand{nodeType=4," - + "cond=SimpleCommand{nodeType=1,command=WORD{true},arguments=[]}," - + "body=SimpleCommand{nodeType=1,command=WORD{echo},arguments=[WORD{$i}]}}", - doTest("while true ; do echo $i ; done")); - } - - public void test9() throws ShellException { - assertEquals( - "LoopCommand{nodeType=5," - + "cond=SimpleCommand{nodeType=1,command=WORD{true},arguments=[]}," - + "body=SimpleCommand{nodeType=1,command=WORD{echo},arguments=[WORD{$i}]}}", - doTest("until true ; do echo $i ; done")); - } - - public void test10() throws ShellException { - assertEquals( - "CaseCommand{nodeType=9,word=WORD{$1},caseItems=[" - + "CaseItem{,pattern=[],body=" - + "SimpleCommand{nodeType=1,command=WORD{ls},arguments=[WORD{-l}]}}," - + "CaseItem{,pattern=[],body=" - + "SimpleCommand{nodeType=1,command=WORD{ls},arguments=[WORD{-a}]}}]}", - doTest("case $1 in ( a ) ls -l ;; b ) ls -a ; esac")); - } - - private String doTest(String input) throws ShellException { - BjorneParser p = new BjorneParser(new BjorneTokenizer(input, DEBUG)); - String res = p.parse().toString(); - if (DEBUG) { - System.err.println(res); - } - return res; - } -} Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java 2009-01-12 08:03:50 UTC (rev 4850) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java 2009-01-12 14:22:05 UTC (rev 4851) @@ -138,21 +138,21 @@ } private void validate() { - switch (tokenType) { - case TOK_WORD: - case TOK_IO_NUMBER: - case TOK_NAME: - case TOK_ASSIGNMENT: - if (text == null || text.length() == 0) { - throw new IllegalArgumentException("null or empty text"); - } - break; - - default: - if (text != null && text.length() > 0) { - throw new IllegalArgumentException("non-empty text"); - } - } +// switch (tokenType) { +// case TOK_WORD: +// case TOK_IO_NUMBER: +// case TOK_NAME: +// case TOK_ASSIGNMENT: +// if (text == null || text.length() == 0) { +// throw new IllegalArgumentException("null or empty text"); +// } +// break; +// +// default: +// if (text != null && text.length() > 0) { +// throw new IllegalArgumentException("non-empty text"); +// } +// } } public String getText() { Deleted: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizerTests.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizerTests.java 2009-01-12 08:03:50 UTC (rev 4850) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizerTests.java 2009-01-12 14:22:05 UTC (rev 4851) @@ -1,553 +0,0 @@ -/* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ - * - * JNode.org - * Copyright (C) 2007-2008 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 static org.jnode.shell.bjorne.BjorneToken.RULE_1_CONTEXT; -import static org.jnode.shell.bjorne.BjorneToken.RULE_5_CONTEXT; -import static org.jnode.shell.bjorne.BjorneToken.RULE_6_CONTEXT; -import static org.jnode.shell.bjorne.BjorneToken.RULE_7a_CONTEXT; -import static org.jnode.shell.bjorne.BjorneToken.RULE_7b_CONTEXT; -import static org.jnode.shell.bjorne.BjorneToken.RULE_8_CONTEXT; -import static org.jnode.shell.bjorne.BjorneToken.TOK_AMP; -import static org.jnode.shell.bjorne.BjorneToken.TOK_AND_IF; -import static org.jnode.shell.bjorne.BjorneToken.TOK_ASSIGNMENT; -import static org.jnode.shell.bjorne.BjorneToken.TOK_BANG; -import static org.jnode.shell.bjorne.BjorneToken.TOK_BAR; -import static org.jnode.shell.bjorne.BjorneToken.TOK_CASE; -import static org.jnode.shell.bjorne.BjorneToken.TOK_CLOBBER; -import static org.jnode.shell.bjorne.BjorneToken.TOK_DGREAT; -import static org.jnode.shell.bjorne.BjorneToken.TOK_DLESS; -import static org.jnode.shell.bjorne.BjorneToken.TOK_DLESSDASH; -import static org.jnode.shell.bjorne.BjorneToken.TOK_DO; -import static org.jnode.shell.bjorne.BjorneToken.TOK_DONE; -import static org.jnode.shell.bjorne.BjorneToken.TOK_DSEMI; -import static org.jnode.shell.bjorne.BjorneToken.TOK_ELIF; -import static org.jnode.shell.bjorne.BjorneToken.TOK_ELSE; -import static org.jnode.shell.bjorne.BjorneToken.TOK_END_OF_LINE; -import static org.jnode.shell.bjorne.BjorneToken.TOK_END_OF_STREAM; -import static org.jnode.shell.bjorne.BjorneToken.TOK_ESAC; -import static org.jnode.shell.bjorne.BjorneToken.TOK_FI; -import static org.jnode.shell.bjorne.BjorneToken.TOK_FOR; -import static org.jnode.shell.bjorne.BjorneToken.TOK_GREAT; -import static org.jnode.shell.bjorne.BjorneToken.TOK_GREATAND; -import static org.jnode.shell.bjorne.BjorneToken.TOK_IF; -import static org.jnode.shell.bjorne.BjorneToken.TOK_IN; -import static org.jnode.shell.bjorne.BjorneToken.TOK_IO_NUMBER; -import static org.jnode.shell.bjorne.BjorneToken.TOK_LBRACE; -import static org.jnode.shell.bjorne.BjorneToken.TOK_LESS; -import static org.jnode.shell.bjorne.BjorneToken.TOK_LESSAND; -import static org.jnode.shell.bjorne.BjorneToken.TOK_LESSGREAT; -import static org.jnode.shell.bjorne.BjorneToken.TOK_LPAREN; -import static org.jnode.shell.bjorne.BjorneToken.TOK_NAME; -import static org.jnode.shell.bjorne.BjorneToken.TOK_OR_IF; -import static org.jnode.shell.bjorne.BjorneToken.TOK_RBRACE; -import static org.jnode.shell.bjorne.BjorneToken.TOK_RPAREN; -import static org.jnode.shell.bjorne.BjorneToken.TOK_SEMI; -import static org.jnode.shell.bjorne.BjorneToken.TOK_THEN; -import static org.jnode.shell.bjorne.BjorneToken.TOK_UNTIL; -import static org.jnode.shell.bjorne.BjorneToken.TOK_WHILE; -import static org.jnode.shell.bjorne.BjorneToken.TOK_WORD; -import junit.framework.TestCase; - -public class BjorneTokenizerTests extends TestCase { - - public void testBjorneTokenizer() { - new BjorneTokenizer("hello"); - } - - public void testEmpty() { - BjorneTokenizer tokenizer = new BjorneTokenizer(""); - BjorneToken token = tokenizer.peek(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - token = tokenizer.peek(RULE_1_CONTEXT); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testNewline() { - BjorneTokenizer tokenizer = new BjorneTokenizer("\n"); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_END_OF_LINE, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testBlanksAndNewlines() { - BjorneTokenizer tokenizer = new BjorneTokenizer(" \n\t\n "); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_END_OF_LINE, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_LINE, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testComments() { - BjorneTokenizer tokenizer = new BjorneTokenizer( - "# comment\n #comment 2\n # comment # 3"); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_END_OF_LINE, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_LINE, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testSymbols() { - BjorneTokenizer tokenizer = new BjorneTokenizer("; | & < > ( )"); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_SEMI, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_BAR, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_AMP, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_LESS, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_GREAT, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_LPAREN, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_RPAREN, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testSymbols2() { - BjorneTokenizer tokenizer = new BjorneTokenizer( - "; ;; | || & && < << > >>"); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_SEMI, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_DSEMI, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_BAR, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_OR_IF, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_AMP, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_AND_IF, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_LESS, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_DLESS, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_GREAT, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_DGREAT, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testSymbols3() { - BjorneTokenizer tokenizer = new BjorneTokenizer(";;;|||&&&<<<>>>"); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_DSEMI, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_SEMI, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_OR_IF, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_BAR, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_AND_IF, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_AMP, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_DLESS, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_LESSGREAT, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_DGREAT, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testSymbols4() { - BjorneTokenizer tokenizer = new BjorneTokenizer( - "< << <<- <& <> > >> >| >&"); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_LESS, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_DLESS, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_DLESSDASH, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_LESSAND, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_LESSGREAT, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_GREAT, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_DGREAT, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_CLOBBER, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_GREATAND, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testWords() { - BjorneTokenizer tokenizer = new BjorneTokenizer("hello there"); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("hello", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("there", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testWords2() { - BjorneTokenizer tokenizer = new BjorneTokenizer( - "hello\\ there\\\n friend"); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("hello\\ there", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("friend", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - - tokenizer = new BjorneTokenizer("hello\\ there\\\n\\ friend"); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("hello\\ there\\ friend", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testWords3() { - BjorneTokenizer tokenizer = new BjorneTokenizer("'1 2' \"3 4\" `5 6`"); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("'1 2'", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("\"3 4\"", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("`5 6`", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testWords4() { - BjorneTokenizer tokenizer = new BjorneTokenizer("'1 \"2\"' \"3\\\"4\""); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("'1 \"2\"'", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("\"3\\\"4\"", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testWords5() { - BjorneTokenizer tokenizer = new BjorneTokenizer("1<2>3&4;5|6)7"); - BjorneToken token = tokenizer.next(); - assertEquals(TOK_IO_NUMBER, token.getTokenType()); - assertEquals("1", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_LESS, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_IO_NUMBER, token.getTokenType()); - assertEquals("2", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_GREAT, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("3", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_AMP, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("4", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_SEMI, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("5", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_BAR, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("6", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_RPAREN, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("7", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testRule1() { - BjorneTokenizer tokenizer = new BjorneTokenizer( - "if then else elif fi for done while until " - + "case { } ! do in esac"); - BjorneToken token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_IF, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_THEN, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_ELSE, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_ELIF, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_FI, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_FOR, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_DONE, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_WHILE, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_UNTIL, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_CASE, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_LBRACE, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_RBRACE, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_BANG, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_DO, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_ESAC, token.getTokenType()); - token = tokenizer.next(RULE_1_CONTEXT); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testRule5() { - BjorneTokenizer tokenizer = new BjorneTokenizer( - "if a a1 9a a_b a,b AB A=b"); - BjorneToken token = tokenizer.next(RULE_5_CONTEXT); - assertEquals(TOK_NAME, token.getTokenType()); - token = tokenizer.next(RULE_5_CONTEXT); - assertEquals(TOK_NAME, token.getTokenType()); - token = tokenizer.next(RULE_5_CONTEXT); - assertEquals(TOK_NAME, token.getTokenType()); - token = tokenizer.next(RULE_5_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_5_CONTEXT); - assertEquals(TOK_NAME, token.getTokenType()); - token = tokenizer.next(RULE_5_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_5_CONTEXT); - assertEquals(TOK_NAME, token.getTokenType()); - token = tokenizer.next(RULE_5_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_5_CONTEXT); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testRule6() { - BjorneTokenizer tokenizer = new BjorneTokenizer("if in do"); - BjorneToken token = tokenizer.next(RULE_6_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_6_CONTEXT); - assertEquals(TOK_IN, token.getTokenType()); - token = tokenizer.next(RULE_6_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_6_CONTEXT); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testRule7a() { - BjorneTokenizer tokenizer = new BjorneTokenizer( - "if then else elif fi for done while until " - + "case { } ! do in esac a= a=b 1a=b =c"); - BjorneToken token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_IF, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_THEN, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_ELSE, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_ELIF, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_FI, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_FOR, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_DONE, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_WHILE, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_UNTIL, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_CASE, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_LBRACE, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_RBRACE, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_BANG, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_DO, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_ESAC, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_ASSIGNMENT, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_ASSIGNMENT, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7a_CONTEXT); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testRule7b() { - BjorneTokenizer tokenizer = new BjorneTokenizer( - "if then else elif fi for done while until " - + "case { } ! do in esac a= a=b 1a=b =c"); - BjorneToken token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_ASSIGNMENT, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_ASSIGNMENT, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_7b_CONTEXT); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testRule8() { - BjorneTokenizer tokenizer = new BjorneTokenizer( - "if then else elif fi for done while until " - + "case { } ! do in esac a a_b a= a=b 1a=b =c"); - BjorneToken token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_IF, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_THEN, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_ELSE, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_ELIF, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_FI, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_FOR, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_DONE, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_WHILE, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_UNTIL, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_CASE, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_LBRACE, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_RBRACE, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_BANG, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_DO, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_NAME, token.getTokenType()); // yes: in -> NAME - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_ESAC, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_NAME, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_NAME, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_ASSIGNMENT, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_ASSIGNMENT, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - token = tokenizer.next(RULE_8_CONTEXT); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } - - public void testRegress() { - BjorneTokenizer tokenizer = new BjorneTokenizer("ls -l"); - BjorneToken token = tokenizer.peek(RULE_7a_CONTEXT); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("ls", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("ls", token.getText()); - token = tokenizer.peek(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("-l", token.getText()); - token = tokenizer.next(); - assertEquals(TOK_WORD, token.getTokenType()); - assertEquals("-l", token.getText()); - token = tokenizer.peek(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - token = tokenizer.next(); - assertEquals(TOK_END_OF_STREAM, token.getTokenType()); - } -} Added: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java 2009-01-12 14:22:05 UTC (rev 4851) @@ -0,0 +1,135 @@ +/* + * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * + * JNode.org + * Copyright (C) 2007-2008 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 java.util.Iterator; +import java.util.List; + +import junit.framework.TestCase; + +import org.jnode.shell.ShellException; +import org.jnode.shell.bjorne.BjorneContext; +import org.jnode.shell.bjorne.BjorneToken; + +public class BjorneContextTests extends TestCase { + + public void testContext() { + new BjorneContext(null, null); + } + + public void testExpand1() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + List<BjorneToken> expansion = context.expandAndSplit(""); + checkExpansion(expansion, new String[] {}); + } + + public void testExpand2() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + List<BjorneToken> expansion = context.expandAndSplit(" "); + checkExpansion(expansion, new String[] {}); + } + + public void testExpand3() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + List<BjorneToken> expansion = context.expandAndSplit("hi"); + checkExpansion(expansion, new String[] {"hi"}); + } + + public void testExpand4() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + List<BjorneToken> expansion = context.expandAndSplit("hi there "); + checkExpansion(expansion, new String[] {"hi", "there"}); + } + + public void testExpand5() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + List<BjorneToken> expansion = context.expandAndSplit("'hi there '"); + checkExpansion(expansion, new String[] {"hi there "}); + } + + public void testExpand6() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + List<BjorneToken> expansion = context.expandAndSplit("\"hi there \" "); + checkExpansion(expansion, new String[] {"hi there "}); + } + + public void testExpand7() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + List<BjorneToken> expansion = context.expandAndSplit("hi\\ there"); + checkExpansion(expansion, new String[] {"hi there"}); + } + + public void testExpand8() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + List<BjorneToken> expansion = context.expandAndSplit("\\\"hi\\ there\\\""); + checkExpansion(expansion, new String[] {"\"hi there\""}); + } + + public void testExpand9() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + List<BjorneToken> expansion = context.expandAndSplit("$?"); + checkExpansion(expansion, new String[] {"0"}); + } + + public void testExpand10() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + context.setVariable("A", "A"); + List<BjorneToken> expansion = context.expandAndSplit("$A"); + checkExpansion(expansion, new String[] {"A"}); + } + + public void testExpand11() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + context.setVariable("A", "A"); + List<BjorneToken> expansion = context.expandAndSplit("\\$A"); + checkExpansion(expansion, new String[] {"$A"}); + } + + public void testExpand12() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + context.setVariable("A", "A"); + List<BjorneToken> expansion = context.expandAndSplit("\"$A\""); + checkExpansion(expansion, new String[] {"A"}); + } + + public void testExpand13() throws ShellException { + BjorneContext context = new BjorneContext(null, null); + context.setVariable("A", "A"); + List<BjorneToken> expansion = context.expandAndSplit("'$A'"); + checkExpansion(expansion, new String[] {"$A"}); + } + + @SuppressWarnings("deprecation") + private void checkExpansion(List<BjorneToken> expansion, String[] expected) { + int i; + Iterator<BjorneToken> it = expansion.iterator(); + for (i = 0; i < expected.length; i++) { + if (it.hasNext()) { + assertEquals("incorrect expansion at word " + i, expected[i], it.next().getText()); + } else { + fail("Too few words in expansion at word " + i + ": expecting '" + expected[i] + "'"); + } + } + if (it.hasNext()) { + fail("Too many words in expansion at word " + i + ": '" + it.next() + "'"); + } + } +} Added: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java 2009-01-12 14:22:05 UTC (rev 4851) @@ -0,0 +1,140 @@ +/* + * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * + * JNode.org + * Copyright (C) 2007-2008 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.BjorneParser; +import org.jnode.shell.bjorne.BjorneTokenizer; + +public class BjorneParserTests extends TestCase { + + private static final boolean DEBUG = true; + + public void testParser() { + new BjorneParser(new BjorneTokenizer("")); + } + + public void test1() throws ShellException { + assertEquals( + "SimpleCommand{nodeType=1,words=[WORD{foo}]}", + doTest("foo")); + } + + public void test2() throws ShellException { + assertEquals( + "SimpleCommand{nodeType=1,words=[WORD{ls},WORD{-l}]}", + doTest("ls -l")); + } + + public void test3() throws ShellException { + assertEquals( + "SimpleCommand{nodeType=1," + + "redirects=[Redirect{redirectionType=60,io=IO_NUMBER{1},arg=WORD{/tmp/foo}}," + + "Redirect{redirectionType=62,arg=WORD{/tmp/bar}}]," + + "words=[WORD{ls},WORD{-l}]}", + doTest("ls -l 1< /tmp/foo > /tmp/bar")); + } + + public void test4() throws ShellException { + assertEquals( + "ListCommand{nodeType=2,flags=0x10," + + "commands=[SimpleCommand{nodeType=1,assignments=[ASSIGNMENT{FOO=BAR}]," + + "words=[WORD{ls},WORD{-l}]}," + + "SimpleCommand{nodeType=1,words=[WORD{less}]}]}", + doTest("FOO=BAR ls -l | less")); + } + + public void test5() throws ShellException { + assertEquals( + "ListCommand{nodeType=2,flags=0x10,commands=[" + + "SimpleCommand{nodeType=1,words=[WORD{cat},WORD{foo}]}," + + "ListCommand{nodeType=10,commands=[" + + "ListCommand{nodeType=2,commands=[" + + "SimpleCommand{nodeType=1,words=[WORD{wc},WORD{1}]}," + + "SimpleCommand{nodeType=1,flags=0x2,words=[WORD{wc},WORD{2}]}]}," + + "ListCommand{nodeType=2,commands=[" + + "SimpleCommand{nodeType=1,words=[WORD{wc},WORD{3}]}," + + "SimpleCommand{nodeType=1,flags=0x4,words=[WORD{wc},WORD{4}]}]}]}]}", + doTest("cat foo | ( wc 1 && wc 2 ; wc 3 || wc 4 )")); + } + + public void test6() throws ShellException { + assertEquals( + "ListCommand{nodeType=2,commands=[" + + "SimpleCommand{nodeType=1,flags=0x1,words=[WORD{cat},WORD{foo}]}," + + "SimpleCommand{nodeType=1,words=[WORD{cat},WORD{bar}]}," + + "SimpleCommand{nodeType=1,words=[WORD{cat},WORD{baz}]}]}", + doTest("cat foo & cat bar ; cat baz ;")); + } + + public void test7() throws ShellException { + assertEquals( + "LoopCommand{nodeType=3,var=NAME{i}," + + "words=[WORD{1},WORD{2},WORD{3},WORD{4},WORD{5}]," + + "body=SimpleCommand{nodeType=1,words=[WORD{echo},WORD{$i}]}}", + doTest("for i in 1 2 3 4 5 ; do echo $i ; done")); + } + + public void test7a() throws ShellException { + assertEquals( + "LoopCommand{nodeType=3,var=NAME{i}," + + "words=[WORD{1},WORD{2},WORD{3},WORD{4},WORD{5}]," + + "body=SimpleCommand{nodeType=1,words=[WORD{echo},WORD{$i}]}}", + doTest("for i in 1 2 3 4 5 ; do \n echo $i ; done")); + } + + public void test8() throws ShellException { + assertEquals( + "LoopCommand{nodeType=4," + + "cond=SimpleCommand{nodeType=1,words=[WORD{true}]}," + + "body=SimpleCommand{nodeType=1,words=[WORD{echo},WORD{$i}]}}", + doTest("while true ; do echo $i ; done")); + } + + public void test9() throws ShellException { + assertEquals( + "LoopCommand{nodeType=5," + + "cond=SimpleCommand{nodeType=1,words=[WORD{true}]}," + + "body=SimpleCommand{nodeType=1,words=[WORD{echo},WORD{$i}]}}", + doTest("until true ; do echo $i ; done")); + } + + public void test10() throws ShellException { + assertEquals( + "CaseCommand{nodeType=9,word=WORD{$1},caseItems=[" + + "CaseItem{,pattern=[],body=" + + "SimpleCommand{nodeType=1,words=[WORD{ls},WORD{-l}]}}," + + "CaseItem{,pattern=[],body=" + + "SimpleCommand{nodeType=1,words=[WORD{ls},WORD{-a}]}}]}", + doTest("case $1 in ( a ) ls -l ;; b ) ls -a ; esac")); + } + + private String doTest(String input) throws ShellException { + BjorneParser p = new BjorneParser(new BjorneTokenizer(input, DEBUG)); + String res = p.parse().toString(); + if (DEBUG) { + System.err.println(res); + } + return res; + } +} Added: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java 2009-01-12 14:22:05 UTC (rev 4851) @@ -0,0 +1,557 @@ +/* + * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * + * JNode.org + * Copyright (C) 2007-2008 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 static org.jnode.shell.bjorne.BjorneToken.RULE_1_CONTEXT; +import static org.jnode.shell.bjorne.BjorneToken.RULE_5_CONTEXT; +import static org.jnode.shell.bjorne.BjorneToken.RULE_6_CONTEXT; +import static org.jnode.shell.bjorne.BjorneToken.RULE_7a_CONTEXT; +import static org.jnode.shell.bjorne.BjorneToken.RULE_7b_CONTEXT; +import static org.jnode.shell.bjorne.BjorneToken.RULE_8_CONTEXT; +import static org.jnode.shell.bjorne.BjorneToken.TOK_AMP; +import static org.jnode.shell.bjorne.BjorneToken.TOK_AND_IF; +import static org.jnode.shell.bjorne.BjorneToken.TOK_ASSIGNMENT; +import static org.jnode.shell.bjorne.BjorneToken.TOK_BANG; +import static org.jnode.shell.bjorne.BjorneToken.TOK_BAR; +import static org.jnode.shell.bjorne.BjorneToken.TOK_CASE; +import static org.jnode.shell.bjorne.BjorneToken.TOK_CLOBBER; +import static org.jnode.shell.bjorne.BjorneToken.TOK_DGREAT; +import static org.jnode.shell.bjorne.BjorneToken.TOK_DLESS; +import static org.jnode.shell.bjorne.BjorneToken.TOK_DLESSDASH; +import static org.jnode.shell.bjorne.BjorneToken.TOK_DO; +import static org.jnode.shell.bjorne.BjorneToken.TOK_DONE; +import static org.jnode.shell.bjorne.BjorneToken.TOK_DSEMI; +import static org.jnode.shell.bjorne.BjorneToken.TOK_ELIF; +import static org.jnode.shell.bjorne.BjorneToken.TOK_ELSE; +import static org.jnode.shell.bjorne.BjorneToken.TOK_END_OF_LINE; +import static org.jnode.shell.bjorne.BjorneToken.TOK_END_OF_STREAM; +import static org.jnode.shell.bjorne.BjorneToken.TOK_ESAC; +import static org.jnode.shell.bjorne.BjorneToken.TOK_FI; +import static org.jnode.shell.bjorne.BjorneToken.TOK_FOR; +import static org.jnode.shell.bjorne.BjorneToken.TOK_GREAT; +import static org.jnode.shell.bjorne.BjorneToken.TOK_GREATAND; +import static org.jnode.shell.bjorne.BjorneToken.TOK_IF; +import static org.jnode.shell.bjorne.BjorneToken.TOK_IN; +import static org.jnode.shell.bjorne.BjorneToken.TOK_IO_NUMBER; +import static org.jnode.shell.bjorne.BjorneToken.TOK_LBRACE; +import static org.jnode.shell.bjorne.BjorneToken.TOK_LESS; +import static org.jnode.shell.bjorne.BjorneToken.TOK_LESSAND; +import static org.jnode.shell.bjorne.BjorneToken.TOK_LESSGREAT; +import static org.jnode.shell.bjorne.BjorneToken.TOK_LPAREN; +import static org.jnode.shell.bjorne.BjorneToken.TOK_NAME; +import static org.jnode.shell.bjorne.BjorneToken.TOK_OR_IF; +import static org.jnode.shell.bjorne.BjorneToken.TOK_RBRACE; +import static org.jnode.shell.bjorne.BjorneToken.TOK_RPAREN; +import static org.jnode.shell.bjorne.BjorneToken.TOK_SEMI; +import static org.jnode.shell.bjorne.BjorneToken.TOK_THEN; +import static org.jnode.shell.bjorne.BjorneToken.TOK_UNTIL; +import static org.jnode.shell.bjorne.BjorneToken.TOK_WHILE; +import static org.jnode.shell.bjorne.BjorneToken.TOK_WORD; + +import org.jnode.shell.bjorne.BjorneToken; +import org.jnode.shell.bjorne.BjorneTokenizer; + +import junit.framework.TestCase; + +public class BjorneTokenizerTests extends TestCase { + + public void testBjorneTokenizer() { + new BjorneTokenizer("hello"); + } + + public void testEmpty() { + BjorneTokenizer tokenizer = new BjorneTokenizer(""); + BjorneToken token = tokenizer.peek(); + assertEquals(TOK_END_OF_STREAM, token.getTokenType()); + token = tokenizer.peek(RULE_1_CONTEXT); + assertEquals(TOK_END_OF_STREAM, token.getTokenType()); + token = tokenizer.next(); + assertEquals(TOK_END_OF_STREAM, token.getTokenType()); + token = tokenizer.next(RULE_1_CONTEXT); + assertEquals(TOK_END_OF_STREAM, token.getTokenType()); + } + + public void testNewline() { + BjorneTokenizer tokenizer = new BjorneTokenizer("\n"); + BjorneToken token = tokenizer.next(); + assertEquals(TOK_END_OF_LINE, token.getTokenType()); + token = tokenizer.next(); + assertEquals(TOK_END_OF_STREAM, token.getTok... [truncated message content] |
From: <cr...@us...> - 2009-01-14 13:58:20
|
Revision: 4862 http://jnode.svn.sourceforge.net/jnode/?rev=4862&view=rev Author: crawley Date: 2009-01-14 13:58:05 +0000 (Wed, 14 Jan 2009) Log Message: ----------- Minor bjorne internal interface changes + extra unit tests Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/CommandLine.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-01-14 13:56:47 UTC (rev 4861) +++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-01-14 13:58:05 UTC (rev 4862) @@ -335,6 +335,10 @@ } return arguments; } + + public Token[] getArgumentTokens() { + return argumentTokens; + } /** * Get the arguments as String[]. Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-01-14 13:56:47 UTC (rev 4861) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-01-14 13:58:05 UTC (rev 4862) @@ -38,6 +38,7 @@ import java.io.InputStream; import java.io.PrintStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -111,7 +112,7 @@ private int lastAsyncPid; - private boolean tildes = true; + private boolean tildeExpansion = true; private boolean globbing = true; @@ -143,8 +144,26 @@ this.interpreter = parent.interpreter; this.holders = copyStreamHolders(parent.holders); this.variables = copyVariables(parent.variables); + this.globbing = parent.globbing; + this.tildeExpansion = parent.tildeExpansion; } + + public boolean isTildeExpansion() { + return tildeExpansion; + } + public void setTildeExpansion(boolean tildeExpansion) { + this.tildeExpansion = tildeExpansion; + } + + public boolean isGlobbing() { + return globbing; + } + + public void setGlobbing(boolean globbing) { + this.globbing = globbing; + } + /** * Create a deep copy of some variable bindings */ @@ -233,8 +252,8 @@ * @return the command line * @throws ShellException */ - public CommandLine expandAndSplit(BjorneToken[] tokens) throws ShellException { - LinkedList<BjorneToken> wordTokens = new LinkedList<BjorneToken>(); + public CommandLine expandAndSplit(Iterable<BjorneToken> tokens) throws ShellException { + List<BjorneToken> wordTokens = new LinkedList<BjorneToken>(); for (BjorneToken token : tokens) { String word = token.getText(); CharSequence expanded = expand(word); @@ -249,6 +268,10 @@ } return makeCommandLine(wordTokens); } + + public CommandLine expandAndSplit(BjorneToken[] tokens) throws ShellException { + return expandAndSplit(Arrays.asList(tokens)); + } /** * Perform expand-and-split processing on a sequence of characters. This method is only @@ -263,11 +286,11 @@ return split(expand(text)); } - private CommandLine makeCommandLine(LinkedList<BjorneToken> wordTokens) { - if (globbing || tildes) { - LinkedList<BjorneToken> globbedWordTokens = new LinkedList<BjorneToken>(); + private CommandLine makeCommandLine(List<BjorneToken> wordTokens) { + if (globbing || tildeExpansion) { + List<BjorneToken> globbedWordTokens = new LinkedList<BjorneToken>(); for (BjorneToken wordToken : wordTokens) { - if (tildes) { + if (tildeExpansion) { wordToken = tildeExpand(wordToken); } if (globbing) { @@ -282,7 +305,7 @@ if (nosWords == 0) { return new CommandLine(null, null); } else { - BjorneToken alias = wordTokens.removeFirst(); + BjorneToken alias = wordTokens.remove(0); BjorneToken[] args = wordTokens.toArray(new BjorneToken[nosWords - 1]); return new CommandLine(alias, args, null); } @@ -306,7 +329,7 @@ } } - private void globAndAppend(BjorneToken wordToken, LinkedList<BjorneToken> globbedWordTokens) { + private void globAndAppend(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)) { @@ -333,8 +356,8 @@ * @return the destination for the tokens. * @throws ShellException */ - public LinkedList<BjorneToken> split(CharSequence text) throws ShellException { - LinkedList<BjorneToken> wordTokens = new LinkedList<BjorneToken>(); + public List<BjorneToken> split(CharSequence text) throws ShellException { + List<BjorneToken> wordTokens = new LinkedList<BjorneToken>(); splitAndAppend(new BjorneToken(BjorneToken.TOK_WORD, text.toString(), -1, -1), wordTokens); return wordTokens; } @@ -347,7 +370,7 @@ * @param wordTokens the destination for the tokens. * @throws ShellException */ - private void splitAndAppend(BjorneToken token, LinkedList<BjorneToken> wordTokens) + private void splitAndAppend(BjorneToken token, List<BjorneToken> wordTokens) throws ShellException { String text = token.getText(); StringBuffer sb = null; @@ -941,6 +964,8 @@ // TODO Auto-generated method stub return false; } + + private static class VariableSlot { @@ -962,7 +987,7 @@ } } - static class StreamHolder { + public static class StreamHolder { public final CommandIO stream; private boolean isMine; Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java 2009-01-14 13:56:47 UTC (rev 4861) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java 2009-01-14 13:58:05 UTC (rev 4862) @@ -20,11 +20,14 @@ */ package org.jnode.test.shell.bjorne; +import java.io.File; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import junit.framework.TestCase; +import org.jnode.shell.CommandLine; import org.jnode.shell.ShellException; import org.jnode.shell.bjorne.BjorneContext; import org.jnode.shell.bjorne.BjorneToken; @@ -117,6 +120,38 @@ checkExpansion(expansion, new String[] {"$A"}); } + public void testExpand14() throws ShellException { + BjorneContext parentContext = new BjorneContext(null, new BjorneContext.StreamHolder[0]); + parentContext.setVariable("A", "A"); + BjorneContext context = new BjorneContext(parentContext); + List<BjorneToken> expansion = context.expandAndSplit("'$A'"); + checkExpansion(expansion, new String[] {"$A"}); + } + + public void testExpand15() throws Exception { + BjorneContext context = new BjorneContext(null, null); + assertEquals(true, context.isGlobbing()); + assertEquals(true, context.isTildeExpansion()); + if (new File("../README.txt").exists()) { + CommandLine expansion = context.expandAndSplit(context.split("../README.*")); + checkExpansion(expansion, new String[] {"../README.txt"}); + } + context.setGlobbing(false); + CommandLine expansion = context.expandAndSplit(context.split("../README.*")); + checkExpansion(expansion, new String[] {"../README.*"}); + } + + public void testExpand16() throws Exception { + BjorneContext context = new BjorneContext(null, null); + assertEquals(true, context.isGlobbing()); + assertEquals(true, context.isTildeExpansion()); + CommandLine expansion = context.expandAndSplit(context.split("~")); + checkExpansion(expansion, new String[] {System.getProperty("user.home")}); + context.setTildeExpansion(false); + expansion = context.expandAndSplit(context.split("~")); + checkExpansion(expansion, new String[] {"~"}); + } + @SuppressWarnings("deprecation") private void checkExpansion(List<BjorneToken> expansion, String[] expected) { int i; @@ -132,4 +167,13 @@ fail("Too many words in expansion at word " + i + ": '" + it.next() + "'"); } } + + private void checkExpansion(CommandLine expansion, String[] expected) { + List<BjorneToken> words = new LinkedList<BjorneToken>(); + words.add((BjorneToken) expansion.getCommandToken()); + for (CommandLine.Token word : expansion.getArgumentTokens()) { + words.add((BjorneToken) word); + } + checkExpansion(words, expected); + } } Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java 2009-01-14 13:56:47 UTC (rev 4861) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java 2009-01-14 13:58:05 UTC (rev 4862) @@ -128,6 +128,23 @@ + "SimpleCommand{nodeType=1,words=[WORD{ls},WORD{-a}]}}]}", doTest("case $1 in ( a ) ls -l ;; b ) ls -a ; esac")); } + + public void test11() throws ShellException { + assertEquals( + "IfCommand{nodeType=6,cond=" + + "SimpleCommand{nodeType=1,words=[WORD{true}]},thenPart=" + + "SimpleCommand{nodeType=1,words=[WORD{echo},WORD{yes}]}}", + doTest("if true ; then echo yes ; fi")); + } + + public void test12() throws ShellException { + assertEquals( + "IfCommand{nodeType=6,cond=" + + "SimpleCommand{nodeType=1,words=[WORD{true}]},thenPart=" + + "SimpleCommand{nodeType=1,words=[WORD{echo},WORD{yes}]},elsePart=" + + "SimpleCommand{nodeType=1,words=[WORD{echo},WORD{false}]}}", + doTest("if true ; then echo yes ; else echo false ; fi")); + } private String doTest(String input) throws ShellException { BjorneParser p = new BjorneParser(new BjorneTokenizer(input, DEBUG)); Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java 2009-01-14 13:56:47 UTC (rev 4861) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java 2009-01-14 13:58:05 UTC (rev 4862) @@ -65,12 +65,11 @@ import static org.jnode.shell.bjorne.BjorneToken.TOK_UNTIL; import static org.jnode.shell.bjorne.BjorneToken.TOK_WHILE; import static org.jnode.shell.bjorne.BjorneToken.TOK_WORD; +import junit.framework.TestCase; import org.jnode.shell.bjorne.BjorneToken; import org.jnode.shell.bjorne.BjorneTokenizer; -import junit.framework.TestCase; - public class BjorneTokenizerTests extends TestCase { public void testBjorneTokenizer() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-01-24 04:02:54
|
Revision: 4905 http://jnode.svn.sourceforge.net/jnode/?rev=4905&view=rev Author: crawley Date: 2009-01-24 04:02:50 +0000 (Sat, 24 Jan 2009) Log Message: ----------- More work on the command test harness, etc 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/CommandShell.java trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.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/TestSpecification.java trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java Added Paths: ----------- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.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 Modified: trunk/shell/src/emu/org/jnode/emu/DeviceManager.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/DeviceManager.java 2009-01-24 02:16:41 UTC (rev 4904) +++ trunk/shell/src/emu/org/jnode/emu/DeviceManager.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; + import org.apache.log4j.Logger; import org.jnode.driver.AbstractDeviceManager; import org.jnode.driver.Device; Modified: trunk/shell/src/emu/org/jnode/emu/Emu.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-01-24 02:16:41 UTC (rev 4904) +++ trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -51,9 +51,9 @@ * An Emu is also a large flightless bird ... which seems kind of appropriate. * * @author Levente S\u00e1ntha - * @author Stephen Crawley + * @author cr...@jn... */ -public abstract class Emu { +public class Emu { private static final String[] ALL_PROJECTS = new String[]{ "core", "distr", "fs", "gui", "net", "shell", "sound", "textui" }; Modified: trunk/shell/src/emu/org/jnode/emu/EmuException.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/EmuException.java 2009-01-24 02:16:41 UTC (rev 4904) +++ trunk/shell/src/emu/org/jnode/emu/EmuException.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -2,6 +2,8 @@ public class EmuException extends Exception { + private static final long serialVersionUID = 1L; + public EmuException(String message) { super(message); } Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-01-24 02:16:41 UTC (rev 4904) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -921,7 +921,7 @@ * @param stream A real stream or a stream marker * @return the real stream that the first argument maps to. */ - CommandIO resolveStream(CommandIO stream) { + protected CommandIO resolveStream(CommandIO stream) { if (stream == CommandLine.DEFAULT_STDIN) { return getInputStream(); } else if (stream == CommandLine.DEFAULT_STDOUT) { Added: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -0,0 +1,31 @@ +package org.jnode.test.shell.bjorne; + +import javax.naming.NamingException; + +import org.jnode.naming.InitialNaming; +import org.jnode.shell.CommandInterpreter; +import org.jnode.shell.ShellManager; +import org.jnode.shell.bjorne.BjorneInterpreter; + +public class BjornePseudoPlugin { + private static final CommandInterpreter.Factory FACTORY = new CommandInterpreter.Factory() { + public CommandInterpreter create() { + return new BjorneInterpreter(); + } + + public String getName() { + return "bjorne"; + } + }; + + /** + * Initialize a new instance + * + * @param descriptor + */ + public BjornePseudoPlugin() throws NamingException { + ShellManager mgr = InitialNaming.lookup(ShellManager.NAME); + mgr.registerInterpreterFactory(FACTORY); + } + +} Added: 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 (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-01-24 04:02:50 UTC (rev 4905) @@ -0,0 +1,30 @@ +<testSpecs> +<testSpec> +<title>simple</title> +<command>test</command> +<runMode>AS_SCRIPT</runMode> +<plugins> +<plugin> +<id>org.jnode.shell.bjorne</id> +<class>org.jnode.test.shell.bjorne.BjornePseudoPlugin</class> +</plugin> +</plugins> +<script>#!bjorne +echo HI +</script> +<output>HI +</output> +<rc>0</rc> +</testSpec> +<testSpec> +<title>#if ... then ... fi</title> +<command>test</command> +<runMode>AS_SCRIPT</runMode> +<script>#!bjorne +if true ; then echo HI ; fi +</script> +<output>HI +</output> +<rc>0</rc> +</testSpec> +</testSpecs> \ No newline at end of file Modified: trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml 2009-01-24 02:16:41 UTC (rev 4904) +++ trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml 2009-01-24 04:02:50 UTC (rev 4905) @@ -1,12 +1,12 @@ <testSpecs> <testSpec> -<title>Test 'true'</title> +<title>true command</title> <command>org.jnode.shell.command.posix.TrueCommand</command> <runMode>AS_ALIAS</runMode> <rc>0</rc> </testSpec> <testSpec> -<title>Test 'false'</title> +<title>false command</title> <command>org.jnode.shell.command.posix.FalseCommand</command> <runMode>AS_ALIAS</runMode> <rc>1</rc> Modified: trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-01-24 02:16:41 UTC (rev 4904) +++ trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -5,9 +5,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.PrintStream; -import java.lang.reflect.Method; import org.jnode.shell.CommandInfo; import org.jnode.shell.CommandInvoker; @@ -20,7 +18,7 @@ /** - * This TestRunner runs a a class by calling its 'static void main(Sting[])' entry + * This TestRunner runs a class by calling its 'static void main(String[])' entry * point. Note that classes that call System.exit(status) are problematic. * * @author cr...@jn... @@ -32,56 +30,22 @@ private final TestSpecification spec; private final TestHarness harness; + private final CommandShell shell; @SuppressWarnings("unused") private final boolean usingEmu; - - private static boolean emuInitialized; - private static boolean emuAvailable; - private static CommandShell shell; public CommandTestRunner(TestSpecification spec, TestHarness harness) { this.spec = spec; this.harness = harness; - this.usingEmu = initEmu(harness.getRoot()); + this.usingEmu = TestEmu.initEmu(harness.getRoot()); + this.shell = TestEmu.getShell(); } - private static synchronized boolean initEmu(File root) { - if (!emuInitialized) { - // This is a bit of a hack. We don't want class loader dependencies - // on the Emu code because that won't work when we run on JNode. But - // we need to use Emu if we are running tests on the dev't platform. - // The following infers that we are running on the dev't platform if - // the 'Emu' class is not loadable. - try { - Class<?> cls = Class.forName("org.jnode.emu.Emu"); - Method initMethod = cls.getMethod("initEnv", File.class); - initMethod.invoke(null, root); - emuAvailable = true; - } catch (Throwable ex) { - // debug ... - ex.printStackTrace(System.err); - emuAvailable = false; - } - try { - if (emuAvailable) { - shell = new CommandShell(); - } else { - shell = (CommandShell) ShellUtils.getCurrentShell(); - } - } catch (Exception ex) { - // debug ... - ex.printStackTrace(System.err); - throw new RuntimeException(ex); - } - emuInitialized = true; - } - return emuAvailable; - } - @Override public int run() throws Exception { String[] args = spec.getArgs().toArray(new String[0]); + // FIXME change this to a shell provided by getShell??? AliasManager aliasMgr = ShellUtils.getAliasManager(); CommandInvoker invoker = new ThreadCommandInvoker(shell); CommandLine cmdLine = new CommandLine(spec.getCommand(), args); @@ -94,13 +58,13 @@ Thread.currentThread().getContextClassLoader(); cmdInfo = new CommandInfo(cl.loadClass(spec.getCommand()), false); } - invoker.invoke(cmdLine, cmdInfo); - return check() ? 0 : 1; + int rc = invoker.invoke(cmdLine, cmdInfo); + return check(rc) ? 0 : 1; } - private boolean check() { - // When a class is run this way we cannot capture the RC. + private boolean check(int rc) { return + harness.expect(rc, spec.getRc(), "return code") && harness.expect(outBucket.toString(), spec.getOutputContent(), "output content") && harness.expect(errBucket.toString(), spec.getErrorContent(), "err content"); } Added: trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -0,0 +1,68 @@ +package org.jnode.test.shell.harness; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +import org.jnode.naming.InitialNaming; +import org.jnode.plugin.PluginManager; +import org.jnode.shell.CommandShell; +import org.jnode.shell.ShellException; +import org.jnode.test.shell.harness.TestSpecification.PluginSpec; + +public abstract class JNodeTestRunnerBase implements TestRunnable { + protected ByteArrayOutputStream outBucket; + protected ByteArrayOutputStream errBucket; + + protected final TestSpecification spec; + protected final TestHarness harness; + + protected final boolean usingEmu; + + public JNodeTestRunnerBase(TestSpecification spec, TestHarness harness) { + super(); + this.spec = spec; + this.harness = harness; + this.usingEmu = TestEmu.initEmu(harness.getRoot()); + } + + public CommandShell getShell() throws ShellException { + CommandShell shell = TestEmu.getShell(); + if (shell == null) { + shell = new TestCommandShell(System.in, System.out, System.err); + shell.configureShell(); + } + return shell; + } + + @Override + public void cleanup() { + } + + @Override + public void setup() { + for (PluginSpec plugin : spec.getRequiredPlugins()) { + ensurePluginLoaded(plugin); + } + System.setIn(new ByteArrayInputStream(spec.getInputContent().getBytes())); + outBucket = new ByteArrayOutputStream(); + errBucket = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outBucket)); + System.setErr(new PrintStream(errBucket)); + } + + protected void ensurePluginLoaded(PluginSpec pluginSpec) { + if (usingEmu) { + TestEmu.loadPseudoPlugin(pluginSpec.pseudoPluginClassName); + } else { + String ver = (pluginSpec.pluginVersion.length() == 0) ? + System.getProperty("os.version") : pluginSpec.pluginVersion; + try { + PluginManager mgr = InitialNaming.lookup(PluginManager.NAME); + mgr.getRegistry().loadPlugin(mgr.getLoaderManager(), pluginSpec.pluginId, ver); + } catch (Exception ex) { + throw new RuntimeException("Cannot load plugin '" + pluginSpec.pluginId + "/" + ver + "'"); + } + } + } +} Added: trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -0,0 +1,5 @@ +package org.jnode.test.shell.harness; + +public interface PseudoPlugin { + +} Added: trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -0,0 +1,58 @@ +/** + * + */ +package org.jnode.test.shell.harness; + +import java.io.File; +import java.io.FileWriter; +import java.io.Writer; + + +/** + * This TestRunner runs a script + * + * @author cr...@jn... + */ +class ScriptTestRunner extends JNodeTestRunnerBase implements TestRunnable { + + + + private File tempScriptFile; + + public ScriptTestRunner(TestSpecification spec, TestHarness harness) { + super(spec, harness); + } + + @Override + public int run() throws Exception { +// String[] args = spec.getArgs().toArray(new String[0]); +// CommandLine cmdLine = new CommandLine(spec.getCommand(), args); + tempScriptFile = new File(System.getProperty("java.io.tmpdir"), spec.getCommand()); + Writer w = null; + try { + w = new FileWriter(tempScriptFile); + w.write(spec.getScriptContent()); + w.write('\n'); + } finally { + w.close(); + } + int rc = getShell().runCommandFile(tempScriptFile); + return check(rc) ? 0 : 1; + } + + private boolean check(int rc) { + return + // harness.expect(rc, spec.getRc(), "return code") && + harness.expect(outBucket.toString(), spec.getOutputContent(), "output content") && + harness.expect(errBucket.toString(), spec.getErrorContent(), "err content"); + } + + @Override + public void cleanup() { + if (tempScriptFile != null) { + tempScriptFile.delete(); + } + super.cleanup(); + } + +} \ No newline at end of file Added: trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -0,0 +1,75 @@ +package org.jnode.test.shell.harness; + +import java.io.File; +import java.io.InputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.Writer; + +import org.jnode.driver.console.CompletionInfo; +import org.jnode.driver.console.ConsoleEvent; +import org.jnode.driver.console.InputHistory; +import org.jnode.driver.console.TextConsole; +import org.jnode.shell.CommandInfo; +import org.jnode.shell.CommandInterpreter; +import org.jnode.shell.CommandInvoker; +import org.jnode.shell.CommandLine; +import org.jnode.shell.CommandShell; +import org.jnode.shell.CommandThread; +import org.jnode.shell.ShellException; +import org.jnode.shell.alias.AliasManager; +import org.jnode.shell.io.CommandIO; +import org.jnode.shell.io.CommandInput; +import org.jnode.shell.io.CommandInputOutput; +import org.jnode.shell.io.CommandOutput; +import org.jnode.shell.io.NullInputStream; +import org.jnode.shell.io.NullOutputStream; +import org.jnode.shell.syntax.ArgumentBundle; +import org.jnode.shell.syntax.SyntaxManager; + +/** + * This class modify the shell's stream resolution mechanism so that + * in/out/err resolve to the streams supplied in the constructor. + * + * @author cr...@jn... + */ +public class TestCommandShell extends CommandShell { + + private final CommandInput cin; + private final CommandOutput cout; + private final CommandOutput cerr; + + public TestCommandShell(InputStream in, PrintStream out, PrintStream err) + throws ShellException { + super(); + this.cin = new CommandInput(in); + this.cout = new CommandOutput(out); + this.cerr = new CommandOutput(err); + } + + @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; + } else if (stream == CommandLine.DEFAULT_STDOUT) { + return cout; + } else if (stream == CommandLine.DEFAULT_STDERR) { + return cerr; + } else if (stream == CommandLine.DEVNULL || stream == null) { + return new CommandInputOutput(new NullInputStream(), new NullOutputStream()); + } else { + return stream; + } + } +} Added: trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -0,0 +1,83 @@ +package org.jnode.test.shell.harness; + +import java.io.File; +import java.lang.reflect.Constructor; +import java.util.HashSet; +import java.util.Set; + +import org.jnode.shell.CommandShell; +import org.jnode.shell.ShellUtils; + +/** + * This class performs Emu and CommandShell initialization without exposing + * the Emu APIs at the class loader level. + * + * @author cr...@jn... + */ +public class TestEmu { + + private static boolean emuInitialized; + private static boolean emuAvailable; + private static CommandShell shell; + + @SuppressWarnings("unused") + private static Object emuObject; + + private static Set<String> loadedPseudoPlugins = new HashSet<String>(); + + public static synchronized boolean initEmu(File root) { + if (!emuInitialized) { + // This is a bit of a hack. We don't want class loader dependencies + // on the Emu code because that won't work when we run on JNode. But + // we need to use Emu if we are running tests on the dev't platform. + // The following infers that we are running on the dev't platform if + // the 'Emu' class is not loadable. + try { + Class<?> cls = Class.forName("org.jnode.emu.Emu"); + Constructor<?> constructor = cls.getConstructor(File.class); + emuObject = constructor.newInstance(root); + emuAvailable = true; + } catch (Throwable ex) { + // debug ... + ex.printStackTrace(System.err); + emuAvailable = false; + } + try { + if (emuAvailable) { + shell = null; + } else { + shell = (CommandShell) ShellUtils.getCurrentShell(); + } + } catch (Exception ex) { + // debug ... + ex.printStackTrace(System.err); + throw new RuntimeException(ex); + } + emuInitialized = true; + } + return emuAvailable; + } + + public static synchronized CommandShell getShell() { + if (!emuInitialized) { + throw new IllegalStateException("Emu not initialized"); + } + return shell; + } + + public static synchronized void loadPseudoPlugin(String pseudoPluginClassName) { + if (!emuInitialized) { + throw new IllegalStateException("Emu not initialized"); + } + if (!loadedPseudoPlugins.contains(pseudoPluginClassName)) { + try { + Class<?> clazz = Class.forName(pseudoPluginClassName); + clazz.newInstance(); + } catch (Exception ex) { + throw new RuntimeException("Cannot load '" + pseudoPluginClassName + "'", ex); + } + loadedPseudoPlugins.add(pseudoPluginClassName); + } + } + +} Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-01-24 02:16:41 UTC (rev 4904) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -24,8 +24,8 @@ private PrintWriter reportWriter; private int testCount; - private int errorCount; private int failureCount; + private int exceptionCount; private TestSpecification spec = null; private InputStream savedIn; private PrintStream savedOut; @@ -95,8 +95,8 @@ } } } - report("Ran " + testCount + " tests with " + errorCount + - " errors and " + failureCount + " failures"); + report("Ran " + testCount + " tests with " + failureCount + + " test failures and " + exceptionCount + " errors (exceptions)"); } private void usage() { @@ -112,6 +112,7 @@ } private void execute(TestSpecification spec) { + this.spec = spec; reportVerbose("Running test '" + spec.getTitle() + "'"); testCount++; try { @@ -123,6 +124,9 @@ case AS_ALIAS: runner = new CommandTestRunner(spec, this); break; + case AS_SCRIPT: + runner = new ScriptTestRunner(spec, this); + break; default: reportVerbose("Run mode '" + spec.getRunMode() + "' not implemented"); return; @@ -130,14 +134,15 @@ try { setup(); runner.setup(); - errorCount += runner.run(); + failureCount += runner.run(); } finally { runner.cleanup(); cleanup(); } } catch (Throwable ex) { + report("Uncaught exception in test '" + spec.getTitle() + "': stacktrace follows."); ex.printStackTrace(reportWriter); - failureCount++; + exceptionCount++; } reportVerbose("Completed test '" + spec.getTitle() + "'"); } @@ -187,14 +192,18 @@ } } - public boolean expect(Object expected, Object actual, String desc) { + public boolean expect(Object actual, Object expected, String desc) { if (expected.equals(actual)) { return true; } - report("Incorrect test result for '" + desc + "' in test '" + spec.getTitle() + "'"); - report(" expected '" + expected + "': got '" + actual + "'"); + report("Incorrect test result for " + asString(desc) + " in test " + asString(spec.getTitle())); + report(" expected " + asString(expected) + ": got " + asString(actual) + "."); return false; } + + private String asString(Object obj) { + return (obj == null) ? "null" : ("'" + obj + "'"); + } public File getRoot() { // FIXME ... this should be the workspace root. Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java 2009-01-24 02:16:41 UTC (rev 4904) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -5,7 +5,7 @@ * use / extend Runnable because we need to propagate any exceptions * in the {@link TestRunnable.run()} method. * - * @author stephen + * @author cr...@jn... */ public interface TestRunnable { Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java 2009-01-24 02:16:41 UTC (rev 4904) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -11,6 +11,20 @@ */ public class TestSpecification { + public static class PluginSpec { + public final String pluginId; + public final String pluginVersion; + public final String pseudoPluginClassName; + + public PluginSpec(String pluginId, String pluginVersion, + String pseudoPluginClassName) { + super(); + this.pluginId = pluginId; + this.pluginVersion = pluginVersion; + this.pseudoPluginClassName = pseudoPluginClassName; + } + } + public static enum RunMode { AS_SCRIPT, AS_CLASS, @@ -20,19 +34,23 @@ private final RunMode runMode; private final String command; private final List<String> args; + private final String scriptContent; private final String inputContent; private final String outputContent; private final String errorContent; private final String title; + private final List<PluginSpec> requiredPlugins; private final int rc; private final Map<File, String> fileMap; - public TestSpecification(RunMode runMode, String command, + public TestSpecification(RunMode runMode, String command, String scriptContent, String inputContent, String outputContent, String errorContent, - String title, int rc, List<String> args, Map<File, String> fileMap) { + String title, int rc, List<String> args, Map<File, String> fileMap, + List<PluginSpec> requiredPlugins) { super(); this.runMode = runMode; this.command = command; + this.scriptContent = scriptContent; this.inputContent = inputContent; this.outputContent = outputContent; this.errorContent = errorContent; @@ -40,6 +58,7 @@ this.rc = rc; this.args = args; this.fileMap = fileMap; + this.requiredPlugins = requiredPlugins; } public String getOutputContent() { @@ -73,6 +92,10 @@ public List<String> getArgs() { return args; } + + public String getScriptContent() { + return scriptContent; + } public String getInputContent() { return inputContent; @@ -81,4 +104,8 @@ public String getTitle() { return title; } + + public List<PluginSpec> getRequiredPlugins() { + return requiredPlugins; + } } Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java 2009-01-24 02:16:41 UTC (rev 4904) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java 2009-01-24 04:02:50 UTC (rev 4905) @@ -12,6 +12,7 @@ import net.n3.nanoxml.StdXMLReader; import net.n3.nanoxml.XMLParserFactory; +import org.jnode.test.shell.harness.TestSpecification.PluginSpec; import org.jnode.test.shell.harness.TestSpecification.RunMode; public class TestSpecificationParser { @@ -48,33 +49,48 @@ RunMode runMode = RunMode.valueOf(extractElementValue(elem, "runMode", "AS_CLASS")); String title = extractElementValue(elem, "title"); String command = extractElementValue(elem, "command"); + String scriptContent = extractElementValue(elem, "script", ""); String inputContent = extractElementValue(elem, "input", ""); String outputContent = extractElementValue(elem, "output", ""); String errorContent = extractElementValue(elem, "error", ""); int rc; try { - rc = Integer.parseInt(extractElementValue(elem, "error", "0").trim()); + rc = Integer.parseInt(extractElementValue(elem, "rc", "0").trim()); } catch (NumberFormatException ex) { throw new TestSpecificationException("'rc' is not an integer"); } - IXMLElement child = elem.getFirstChildNamed("args"); - List<String> args = new ArrayList<String>(); - if (child != null) { - for (Object obj : child.getChildren()) { + List<String> args = parseArgs(elem.getFirstChildNamed("args")); + Map<File, String> fileMap = parseFiles(elem.getFirstChildNamed("files")); + List<PluginSpec> plugins = parsePlugins(elem.getFirstChildNamed("plugins")); + return new TestSpecification( + runMode, command, scriptContent, inputContent, outputContent, errorContent, + title, rc, args, fileMap, plugins); + } + + private List<PluginSpec> parsePlugins(IXMLElement pluginsElem) throws TestSpecificationException { + List<PluginSpec> plugins = new ArrayList<PluginSpec>(); + if (pluginsElem != null) { + for (Object obj : pluginsElem.getChildren()) { if (obj instanceof IXMLElement) { - IXMLElement argChild = (IXMLElement) obj; - if (!argChild.getName().equals("arg")) { + IXMLElement child = (IXMLElement) obj; + if (!child.getName().equals("plugin")) { throw new TestSpecificationException( - "Child elements of 'args' should be 'arg' not '" + argChild.getName() + "'"); + "Child elements of 'plugins' should be 'plugin' not '" + child.getName() + "'"); } - args.add(argChild.getContent()); + String pluginId = extractElementValue(child, "id"); + String pluginVersion = extractElementValue(child, "version", ""); + String pseudoPluginClassName = extractElementValue(child, "class"); + plugins.add(new PluginSpec(pluginId, pluginVersion, pseudoPluginClassName)); } } } - child = elem.getFirstChildNamed("files"); + return plugins; + } + + private Map<File, String> parseFiles(IXMLElement filesElem) throws TestSpecificationException { Map<File, String> fileMap = new HashMap<File, String>(); - if (child != null) { - for (Object obj : child.getChildren()) { + if (filesElem != null) { + for (Object obj : filesElem.getChildren()) { if (obj instanceof IXMLElement) { IXMLElement fileChild = (IXMLElement) obj; if (!fileChild.getName().equals("file")) { @@ -87,18 +103,34 @@ } } } - return new TestSpecification( - runMode, command, inputContent, outputContent, errorContent, - title, rc, args, fileMap); + return fileMap; } + private List<String> parseArgs(IXMLElement argsElem) throws TestSpecificationException { + List<String> args = new ArrayList<String>(); + if (argsElem != null) { + for (Object obj : argsElem.getChildren()) { + if (obj instanceof IXMLElement) { + IXMLElement argChild = (IXMLElement) obj; + if (!argChild.getName().equals("arg")) { + throw new TestSpecificationException( + "Child elements of 'args' should be 'arg' not '" + argChild.getName() + "'"); + } + args.add(argChild.getContent()); + } + } + } + return args; + } + private String extractElementValue(IXMLElement parent, String name) throws TestSpecificationException { IXMLElement elem = parent.getFirstChildNamed(name); if (elem == null) { throw new TestSpecificationException( "Element '" + name + "' not found in '" + parent.getName() + "'"); } else { - return elem.getContent(); + String res = elem.getContent(); + return (res == null) ? "" : res; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-01-25 01:04:40
|
Revision: 4908 http://jnode.svn.sourceforge.net/jnode/?rev=4908&view=rev Author: crawley Date: 2009-01-25 01:04:36 +0000 (Sun, 25 Jan 2009) Log Message: ----------- Another checkpoint of command test harness, etc Modified Paths: -------------- trunk/shell/src/emu/org/jnode/emu/Emu.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml 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/JNodeTestRunnerBase.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/TestSpecification.java trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java Added Paths: ----------- 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/TestSetSpecification.java Removed Paths: ------------- trunk/shell/src/test/org/jnode/test/shell/harness/Test.java Modified: trunk/shell/src/emu/org/jnode/emu/Emu.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -59,14 +59,21 @@ }; // FIXME configuring a hard-coded list of command plugins is a bad idea. - private static final String[] PLUGIN_NAMES = new String[] { + private static final String[] DEFAULT_PLUGIN_NAMES = new String[] { "org.jnode.shell.command", - "org.jnode.shell.command.posix", "org.jnode.shell.command.driver.console", "org.jnode.apps.editor", "org.jnode.apps.edit", "org.jnode.apps.console", }; + + private final File root; + private final AliasManager aliasMgr; + private final SyntaxManager syntaxMgr; + + public Emu(File root) throws EmuException { + this(root, DEFAULT_PLUGIN_NAMES); + } /** * The constructor initializes a minimal subset of JNode services to allow us to run JNode commands. @@ -74,21 +81,20 @@ * @param root the notional JNode sandbox root directory or <code>null</code>. * @throws EmuException */ - public Emu(File root) throws EmuException { + public Emu(File root, String[] pluginNames) throws EmuException { if (root == null) { root = new File("").getAbsoluteFile(); System.err.println("Assuming that the JNode root is '" + root + "'"); } + this.root = root; InitialNaming.setNameSpace(new BasicNameSpace()); try { InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE); - AliasManager aliasMgr = - new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager(); - SyntaxManager syntaxMgr = - new DefaultSyntaxManager(new DummyExtensionPoint()).createSyntaxManager(); - for (String pluginName : PLUGIN_NAMES) { - configurePluginCommands(root, pluginName, aliasMgr, syntaxMgr); + aliasMgr = new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager(); + syntaxMgr = new DefaultSyntaxManager(new DummyExtensionPoint()).createSyntaxManager(); + for (String pluginName : pluginNames) { + configurePluginCommands(pluginName); } System.setProperty("jnode.invoker", "thread"); System.setProperty("jnode.interpreter", "redirecting"); @@ -105,27 +111,22 @@ /** * Configure any command classes specified by a given plugin's descriptor * - * @param root the root directory for the JNode sandbox. * @param pluginName the plugin to be processed - * @param aliasMgr the alias manager to be populated - * @param syntaxMgr the syntax manager to be populated * @throws EmuException */ - private void configurePluginCommands(File root, String pluginName, AliasManager aliasMgr, - SyntaxManager syntaxMgr) throws EmuException { - XMLElement pluginDescriptor = loadPluginDescriptor(root, pluginName); - extractAliases(pluginDescriptor, aliasMgr); - extractSyntaxBundles(pluginDescriptor, syntaxMgr); + public void configurePluginCommands(String pluginName) throws EmuException { + XMLElement pluginDescriptor = loadPluginDescriptor(pluginName); + extractAliases(pluginDescriptor); + extractSyntaxBundles(pluginDescriptor); } /** * Populate the supplied syntax manager with syntax entries from a plugin descriptor. * * @param pluginDescriptor the plugin descriptor's root XML element - * @param syntaxMgr the syntax manager to be populated. * @throws EmuException */ - private void extractSyntaxBundles(XMLElement pluginDescriptor, SyntaxManager syntaxMgr) + private void extractSyntaxBundles(XMLElement pluginDescriptor) throws EmuException { XMLElement syntaxesDescriptor = findExtension(pluginDescriptor, SyntaxManager.SYNTAXES_EP_NAME); if (syntaxesDescriptor == null) { @@ -152,10 +153,9 @@ * Populate the supplied alias manager with aliases from a plugin descriptor. * * @param pluginDescriptor the plugin descriptor's root XML element - * @param aliasMgr the alias manager to be populated. * @throws EmuException */ - private void extractAliases(XMLElement pluginDescriptor, AliasManager aliasMgr) { + private void extractAliases(XMLElement pluginDescriptor) { XMLElement aliasesDescriptor = findExtension(pluginDescriptor, AliasManager.ALIASES_EP_NAME); if (aliasesDescriptor == null) { return; @@ -190,12 +190,11 @@ * Locate and load a plugin descriptor. We search the "descriptors" directory of * each of the projects listed in ALL_PROJECTS * - * @param root the notional root directory for the user's JNode sandbox. * @param pluginName the name of the plugin we're trying to locate * @return the loaded plugin descriptor or <code>null</code> * @throws EmuException */ - private XMLElement loadPluginDescriptor(File root, String pluginName) + private XMLElement loadPluginDescriptor(String pluginName) throws EmuException { File file = null; for (String projectName : ALL_PROJECTS) { Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,3 +1,23 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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 javax.naming.NamingException; 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-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,14 +1,16 @@ <testSpecs> +<title>Bjorne interpreter tests</title> +<plugin> +<id>org.jnode.shell.bjorne</id> +<class>org.jnode.test.shell.bjorne.BjornePseudoPlugin</class> +</plugin> +<plugin> +<id>org.jnode.shell.command.posix</id> +</plugin> <testSpec> <title>simple</title> <command>test</command> <runMode>AS_SCRIPT</runMode> -<plugins> -<plugin> -<id>org.jnode.shell.bjorne</id> -<class>org.jnode.test.shell.bjorne.BjornePseudoPlugin</class> -</plugin> -</plugins> <script>#!bjorne echo HI </script> Modified: trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,4 +1,8 @@ <testSpecs> +<title>POSIX command tests</title> +<plugin> +<id>org.jnode.shell.command.posix</id> +</plugin> <testSpec> <title>true command</title> <command>org.jnode.shell.command.posix.TrueCommand</command> Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,5 +1,22 @@ -/** - * +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; Modified: trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,5 +1,22 @@ -/** - * +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; Added: trunk/shell/src/test/org/jnode/test/shell/harness/DummyPseudoPlugin.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/DummyPseudoPlugin.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/DummyPseudoPlugin.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -0,0 +1,25 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; + +public class DummyPseudoPlugin implements PseudoPlugin { + // Nothing required. +} Modified: trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,3 +1,23 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; import java.io.ByteArrayInputStream; @@ -8,7 +28,6 @@ import org.jnode.plugin.PluginManager; import org.jnode.shell.CommandShell; import org.jnode.shell.ShellException; -import org.jnode.test.shell.harness.TestSpecification.PluginSpec; public abstract class JNodeTestRunnerBase implements TestRunnable { protected ByteArrayOutputStream outBucket; @@ -41,7 +60,12 @@ @Override public void setup() { - for (PluginSpec plugin : spec.getRequiredPlugins()) { + if (spec.getTestSet() != null) { + for (PluginSpecification plugin : spec.getTestSet().getPlugins()) { + ensurePluginLoaded(plugin); + } + } + for (PluginSpecification plugin : spec.getPlugins()) { ensurePluginLoaded(plugin); } System.setIn(new ByteArrayInputStream(spec.getInputContent().getBytes())); @@ -51,17 +75,18 @@ System.setErr(new PrintStream(errBucket)); } - protected void ensurePluginLoaded(PluginSpec pluginSpec) { + protected void ensurePluginLoaded(PluginSpecification plugin) { if (usingEmu) { - TestEmu.loadPseudoPlugin(pluginSpec.pseudoPluginClassName); + TestEmu.loadPseudoPlugin(plugin.getPluginId(), plugin.getClassName()); } else { - String ver = (pluginSpec.pluginVersion.length() == 0) ? - System.getProperty("os.version") : pluginSpec.pluginVersion; + String ver = (plugin.getPluginVersion().length() == 0) ? + System.getProperty("os.version") : plugin.getPluginVersion(); try { PluginManager mgr = InitialNaming.lookup(PluginManager.NAME); - mgr.getRegistry().loadPlugin(mgr.getLoaderManager(), pluginSpec.pluginId, ver); + mgr.getRegistry().loadPlugin(mgr.getLoaderManager(), plugin.getPluginId(), ver); } catch (Exception ex) { - throw new RuntimeException("Cannot load plugin '" + pluginSpec.pluginId + "/" + ver + "'"); + throw new RuntimeException( + "Cannot load plugin '" + plugin.getPluginId() + "/" + ver + "'"); } } } Added: trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -0,0 +1,47 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; + +public class PluginSpecification { + private final String pluginId; + private final String pluginVersion; + private final String pseudoPluginClassName; + + public PluginSpecification(String pluginId, String pluginVersion, + String pseudoPluginClassName) { + super(); + this.pluginId = pluginId; + this.pluginVersion = pluginVersion; + this.pseudoPluginClassName = pseudoPluginClassName; + } + + public String getPluginId() { + return pluginId; + } + + public String getPluginVersion() { + return pluginVersion; + } + + public String getClassName() { + return pseudoPluginClassName; + } +} \ No newline at end of file Modified: trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,3 +1,23 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; public interface PseudoPlugin { Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,5 +1,22 @@ -/** - * +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; Deleted: trunk/shell/src/test/org/jnode/test/shell/harness/Test.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/Test.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/Test.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,16 +0,0 @@ -package org.jnode.test.shell.harness; - -public class Test { - - /** - * @param args - */ - public static void main(String[] args) { - if (args.length == 0) { - System.out.println("Hi mum"); - } else if (args[0].equals("System.exit")) { - System.exit(1); - } - } - -} Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,3 +1,23 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; import java.io.InputStream; Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,3 +1,23 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; import java.io.File; @@ -2,2 +22,3 @@ import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.util.HashSet; @@ -19,6 +40,7 @@ private static boolean emuInitialized; private static boolean emuAvailable; private static CommandShell shell; + private static Class<?> emuClass; @SuppressWarnings("unused") private static Object emuObject; @@ -33,8 +55,8 @@ // The following infers that we are running on the dev't platform if // the 'Emu' class is not loadable. try { - Class<?> cls = Class.forName("org.jnode.emu.Emu"); - Constructor<?> constructor = cls.getConstructor(File.class); + emuClass = Class.forName("org.jnode.emu.Emu"); + Constructor<?> constructor = emuClass.getConstructor(File.class); emuObject = constructor.newInstance(root); emuAvailable = true; } catch (Throwable ex) { @@ -65,18 +87,20 @@ return shell; } - public static synchronized void loadPseudoPlugin(String pseudoPluginClassName) { + public static synchronized void loadPseudoPlugin(String pluginId, String className) { if (!emuInitialized) { throw new IllegalStateException("Emu not initialized"); } - if (!loadedPseudoPlugins.contains(pseudoPluginClassName)) { + if (!loadedPseudoPlugins.contains(className)) { try { - Class<?> clazz = Class.forName(pseudoPluginClassName); + Class<?> clazz = Class.forName(className); clazz.newInstance(); + Method method = emuClass.getMethod("configurePluginCommands", String.class); + method.invoke(emuObject, pluginId); } catch (Exception ex) { - throw new RuntimeException("Cannot load '" + pseudoPluginClassName + "'", ex); + throw new RuntimeException("Cannot configure plugin '" + pluginId + "'", ex); } - loadedPseudoPlugins.add(pseudoPluginClassName); + loadedPseudoPlugins.add(className); } } Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,3 +1,23 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; import java.io.File; @@ -6,7 +26,6 @@ import java.io.InputStream; import java.io.PrintStream; import java.io.PrintWriter; -import java.util.List; import net.n3.nanoxml.XMLException; @@ -50,7 +69,7 @@ boolean useResources = false; int firstArg = 0; TestSpecificationParser parser = new TestSpecificationParser(); - List<TestSpecification> specs; + TestSetSpecification specs; if (args.length == 0) { usage(); return; @@ -105,8 +124,8 @@ System.err.println(commandName + " <spec-file> ... // run tests from specs read from file system"); } - private void execute(List<TestSpecification> specs) { - for (TestSpecification spec : specs) { + private void execute(TestSetSpecification specs) { + for (TestSpecification spec : specs.getSpecs()) { execute(spec); } } Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,3 +1,23 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; /** Added: trunk/shell/src/test/org/jnode/test/shell/harness/TestSetSpecification.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestSetSpecification.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSetSpecification.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -0,0 +1,41 @@ +package org.jnode.test.shell.harness; + +import java.util.ArrayList; +import java.util.List; + +public class TestSetSpecification { + + private final List<TestSpecification> specs = + new ArrayList<TestSpecification>(); + + private final List<PluginSpecification> plugins = + new ArrayList<PluginSpecification>(); + + private final String title; + + public TestSetSpecification(String title) { + super(); + this.title = title; + } + + public List<TestSpecification> getSpecs() { + return specs; + } + + public List<PluginSpecification> getPlugins() { + return plugins; + } + + public String getTitle() { + return title; + } + + public void addPluginSpec(PluginSpecification plugin) { + plugins.add(plugin); + } + + public void addTestSpec(TestSpecification spec) { + specs.add(spec); + spec.setTestSet(this); + } +} Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,6 +1,28 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -11,20 +33,6 @@ */ public class TestSpecification { - public static class PluginSpec { - public final String pluginId; - public final String pluginVersion; - public final String pseudoPluginClassName; - - public PluginSpec(String pluginId, String pluginVersion, - String pseudoPluginClassName) { - super(); - this.pluginId = pluginId; - this.pluginVersion = pluginVersion; - this.pseudoPluginClassName = pseudoPluginClassName; - } - } - public static enum RunMode { AS_SCRIPT, AS_CLASS, @@ -33,20 +41,20 @@ private final RunMode runMode; private final String command; - private final List<String> args; + private final List<String> args = new ArrayList<String>(); private final String scriptContent; private final String inputContent; private final String outputContent; private final String errorContent; private final String title; - private final List<PluginSpec> requiredPlugins; + private final List<PluginSpecification> plugins = new ArrayList<PluginSpecification>(); private final int rc; - private final Map<File, String> fileMap; + private final Map<File, String> fileMap = new HashMap<File, String>(); + private TestSetSpecification testSet; public TestSpecification(RunMode runMode, String command, String scriptContent, String inputContent, String outputContent, String errorContent, - String title, int rc, List<String> args, Map<File, String> fileMap, - List<PluginSpec> requiredPlugins) { + String title, int rc) { super(); this.runMode = runMode; this.command = command; @@ -56,9 +64,6 @@ this.errorContent = errorContent; this.title = title; this.rc = rc; - this.args = args; - this.fileMap = fileMap; - this.requiredPlugins = requiredPlugins; } public String getOutputContent() { @@ -73,6 +78,14 @@ return rc; } + public void addArg(String arg) { + args.add(arg); + } + + public void addPlugin(PluginSpecification plugin) { + plugins.add(plugin); + } + public void addFile(File file, String content) { fileMap.put(file, content); } @@ -105,7 +118,15 @@ return title; } - public List<PluginSpec> getRequiredPlugins() { - return requiredPlugins; + public List<PluginSpecification> getPlugins() { + return plugins; } + + public TestSetSpecification getTestSet() { + return testSet; + } + + public void setTestSet(TestSetSpecification testSet) { + this.testSet = testSet; + } } Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,3 +1,23 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; public class TestSpecificationException extends Exception { Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java 2009-01-24 05:34:47 UTC (rev 4907) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java 2009-01-25 01:04:36 UTC (rev 4908) @@ -1,3 +1,23 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 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.harness; import java.io.File; @@ -2,6 +22,2 @@ import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; @@ -12,29 +28,31 @@ import net.n3.nanoxml.StdXMLReader; import net.n3.nanoxml.XMLParserFactory; -import org.jnode.test.shell.harness.TestSpecification.PluginSpec; import org.jnode.test.shell.harness.TestSpecification.RunMode; public class TestSpecificationParser { - public List<TestSpecification> parse(InputStream in) throws Exception { + public TestSetSpecification parse(InputStream in) throws Exception { StdXMLReader xr = new StdXMLReader(in); IXMLParser parser = XMLParserFactory.createDefaultXMLParser(); parser.setReader(xr); - List<TestSpecification> res = new ArrayList<TestSpecification>(); + TestSetSpecification res; IXMLElement root = (IXMLElement) parser.parse(); if (root.getName().equals("testSpec")) { - res.add(parseTestSpecification(root)); + res = new TestSetSpecification(""); + res.addTestSpec(parseTestSpecification(root)); } else if (root.getName().equals("testSpecs")) { + String title = extractElementValue(root, "title"); + res = new TestSetSpecification(title); for (Object obj : root.getChildren()) { if (obj instanceof IXMLElement) { IXMLElement argChild = (IXMLElement) obj; - if (!argChild.getName().equals("testSpec")) { - throw new TestSpecificationException( - "Child elements of 'testSpecs' should be 'testSpec' not '" + - argChild.getName() + "'"); - } - res.add(parseTestSpecification(argChild)); + String name = argChild.getName(); + if (name.equals("testSpec")) { + res.addTestSpec(parseTestSpecification(argChild)); + } else if (name.equals("plugin")) { + res.addPluginSpec(parsePluginSpecification(argChild)); + } } } } else { @@ -45,7 +63,6 @@ } private TestSpecification parseTestSpecification(IXMLElement elem) throws TestSpecificationException { - RunMode runMode = RunMode.valueOf(extractElementValue(elem, "runMode", "AS_CLASS")); String title = extractElementValue(elem, "title"); String command = extractElementValue(elem, "command"); @@ -59,70 +76,41 @@ } catch (NumberFormatException ex) { throw new TestSpecificationException("'rc' is not an integer"); } - List<String> args = parseArgs(elem.getFirstChildNamed("args")); - Map<File, String> fileMap = parseFiles(elem.getFirstChildNamed("files")); - List<PluginSpec> plugins = parsePlugins(elem.getFirstChildNamed("plugins")); - return new TestSpecification( + TestSpecification res = new TestSpecification( runMode, command, scriptContent, inputContent, outputContent, errorContent, - title, rc, args, fileMap, plugins); - } - - private List<PluginSpec> parsePlugins(IXMLElement pluginsElem) throws TestSpecificationException { - List<PluginSpec> plugins = new ArrayList<PluginSpec>(); - if (pluginsElem != null) { - for (Object obj : pluginsElem.getChildren()) { - if (obj instanceof IXMLElement) { - IXMLElement child = (IXMLElement) obj; - if (!child.getName().equals("plugin")) { - throw new TestSpecificationException( - "Child elements of 'plugins' should be 'plugin' not '" + child.getName() + "'"); - } - String pluginId = extractElementValue(child, "id"); - String pluginVersion = extractElementValue(child, "version", ""); - String pseudoPluginClassName = extractElementValue(child, "class"); - plugins.add(new PluginSpec(pluginId, pluginVersion, pseudoPluginClassName)); + title, rc); + for (Object obj : elem.getChildren()) { + if (obj instanceof IXMLElement) { + IXMLElement child = (IXMLElement) obj; + String name = child.getName(); + if (name.equals("arg")) { + res.addArg(child.getContent()); + } else if (name.equals("plugin")) { + res.addPlugin(parsePluginSpecification(child)); + } else if (name.equals("file")) { + parseFile(child, res); } } } - return plugins; + return res; } - private Map<File, String> parseFiles(IXMLElement filesElem) throws TestSpecificationException { - Map<File, String> fileMap = new HashMap<File, String>(); - if (filesElem != null) { - for (Object obj : filesElem.getChildren()) { - if (obj instanceof IXMLElement) { - IXMLElement fileChild = (IXMLElement) obj; - if (!fileChild.getName().equals("file")) { - throw new TestSpecificationException( - "Child elements of 'files' should be 'file' not '" + fileChild.getName() + "'"); - } - String fileName = extractElementValue(fileChild, "name"); - String content = extractElementValue(fileChild, "content", ""); - fileMap.put(new File(fileName), content); - } - } - } - return fileMap; + private PluginSpecification parsePluginSpecification(IXMLElement elem) + throws TestSpecificationException { + String pluginId = extractElementValue(elem, "id"); + String pluginVersion = extractElementValue(elem, "version", ""); + String pseudoPluginClassName = extractElementValue(elem, "class", + "org.jnode.test.shell.harness.DummyPseudoPlugin"); + return new PluginSpecification(pluginId, pluginVersion, pseudoPluginClassName); } - private List<String> parseArgs(IXMLElement argsElem) throws TestSpecificationException { - List<String> args = new ArrayList<String>(); - if (argsElem != null) { - for (Object obj : argsElem.getChildren()) { - if (obj instanceof IXMLElement) { - IXMLElement argChild = (IXMLElement) obj; - if (!argChild.getName().equals("arg")) { - throw new TestSpecificationException( - "Child elements of 'args' should be 'arg' not '" + argChild.getName() + "'"); - } - args.add(argChild.getContent()); - } - } - } - return args; + private void parseFile(IXMLElement elem, TestSpecification res) + throws TestSpecificationException { + String fileName = extractElementValue(elem, "name"); + String content = extractElementValue(elem, "content", ""); + res.addFile(new File(fileName), content); } - + private String extractElementValue(IXMLElement parent, String name) throws TestSpecificationException { IXMLElement elem = parent.getFirstChildNamed(name); if (elem == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-01-26 10:18:20
|
Revision: 4914 http://jnode.svn.sourceforge.net/jnode/?rev=4914&view=rev Author: crawley Date: 2009-01-26 10:18:09 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Implemented 'for' loop execution. Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java 2009-01-26 09:39:14 UTC (rev 4913) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java 2009-01-26 10:18:09 UTC (rev 4914) @@ -20,6 +20,8 @@ */ package org.jnode.shell.bjorne; +import org.jnode.shell.ShellException; + public class ForCommandNode extends CommandNode { private final CommandNode body; @@ -60,7 +62,12 @@ } @Override - public int execute(BjorneContext context) { - return -1; + public int execute(BjorneContext context) throws ShellException { + int rc = 0; + for (BjorneToken word : words) { + context.setVariable(var.getText(), word.getText()); + rc = body.execute(context); + } + return rc; } } 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-01-26 09:39:14 UTC (rev 4913) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-01-26 10:18:09 UTC (rev 4914) @@ -19,6 +19,21 @@ <rc>0</rc> </testSpec> <testSpec> + <title>$?</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne +true +echo $? +false +echo $? +</script> + <output>0 +1 +</output> + <rc>0</rc> + </testSpec> + <testSpec> <title>if ... then ... fi</title> <command>test</command> <runMode>AS_SCRIPT</runMode> @@ -30,18 +45,44 @@ <rc>0</rc> </testSpec> <testSpec> - <title>$?</title> + <title>if ... then ... else ... fi</title> <command>test</command> <runMode>AS_SCRIPT</runMode> <script>#!bjorne -true -echo $? -false -echo $? -</script> - <output>0 -1 +if true ; then echo HI ; else echo HO; fi +if false ; then echo HI ; else echo HO; fi + </script> + <output>HI +HO </output> <rc>0</rc> </testSpec> + <testSpec> + <title>if ... then ... elif ... else ... fi</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne +if true ; then echo HI ; elif false ; then echo HO ; else echo HUM; fi +if false ; then echo HI ; elif true ; then echo HO ; else echo HUM; fi +if false ; then echo HI ; elif false ; then echo HO ; else echo HUM; fi + </script> + <output>HI +HO +HUM +</output> + <rc>0</rc> + </testSpec> + <testSpec> + <title>for ... do ... done</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne +for A in 1 2 3 ; do echo $A ; done + </script> + <output>1 +2 +3 +</output> + <rc>0</rc> + </testSpec> </testSpecs> \ 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-02-01 04:53:38
|
Revision: 4951 http://jnode.svn.sourceforge.net/jnode/?rev=4951&view=rev Author: crawley Date: 2009-02-01 04:53:32 +0000 (Sun, 01 Feb 2009) Log Message: ----------- The exit builtin now sets the return code correctly in a script Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-01 03:12:50 UTC (rev 4950) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-01 04:53:32 UTC (rev 4951) @@ -159,7 +159,28 @@ @Override public int interpret(CommandShell shell, String command) throws ShellException { - return interpret(shell, command, null, false); + try { + return interpret(shell, command, null, false); + } catch (BjorneControlException ex) { + switch (ex.getControl()) { + case BjorneInterpreter.BRANCH_EXIT: + // FIXME this is not right. If 'exit' is run in an interactive + // shell, the shell needs to exit. + 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("control exception with bad control code (" + + ex.getControl() + ")"); + } + } } @Override @@ -214,25 +235,25 @@ if (DEBUG) { System.err.println(tree); } - try { +// try { if (capture == null) { // FIXME ... this may add an empty line to the command history shell.addCommandToHistory(command); } return tree.execute((BjorneContext) myContext); - } catch (BjorneControlException ex) { - switch (ex.getControl()) { - case BRANCH_EXIT: - return ex.getCount(); - case BRANCH_BREAK: - case BRANCH_CONTINUE: - return 0; - case BRANCH_RETURN: - return (source) ? ex.getCount() : 1; - default: - throw new ShellFailureException("unknown control " + ex.getControl()); - } - } +// } catch (BjorneControlException ex) { +// switch (ex.getControl()) { +// case BRANCH_EXIT: +// return ex.getCount(); +// case BRANCH_BREAK: +// case BRANCH_CONTINUE: +// return 0; +// case BRANCH_RETURN: +// return (source) ? ex.getCount() : 1; +// default: +// throw new ShellFailureException("unknown control " + ex.getControl()); +// } +// } } @Override @@ -243,7 +264,24 @@ String line; int rc = 0; while ((line = br.readLine()) != null) { - rc = interpret(shell, line); + try { + rc = interpret(shell, line, 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"); + } + } } return rc; } catch (IOException ex) { Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java 2009-02-01 03:12:50 UTC (rev 4950) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java 2009-02-01 04:53:32 UTC (rev 4951) @@ -32,7 +32,7 @@ Iterator<String> args = command.iterator(); if (!args.hasNext()) { throw new BjorneControlException(BjorneInterpreter.BRANCH_EXIT, - context.getLastReturnCode()); + context.getParent().getLastReturnCode()); } else { String arg = args.next(); try { 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-02-01 03:12:50 UTC (rev 4950) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-01 04:53:32 UTC (rev 4951) @@ -112,4 +112,27 @@ </output> <rc>0</rc> </testSpec> + <testSpec> + <title>while ... do ... break ... done</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne +A=5 +while expr $A != 0 ; do echo A is $A ; if expr $A = 2 ; then break ; fi ; A=`expr $A - 1`; done + </script> + <output>1 +A is 5 +0 +1 +A is 4 +0 +1 +A is 3 +0 +1 +A is 2 +1 +</output> + <rc>0</rc> + </testSpec> </testSpecs> \ 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-02-01 09:15:54
|
Revision: 4954 http://jnode.svn.sourceforge.net/jnode/?rev=4954&view=rev Author: crawley Date: 2009-02-01 09:15:46 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Fix for tokenization bug which caused '#' to be treated as a comment start in ${#a}. Also diagnose a missing '}' in ${a. Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.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-02-01 06:49:07 UTC (rev 4953) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-01 09:15:46 UTC (rev 4954) @@ -630,6 +630,10 @@ } ch = ci.nextCh(); } + + if (braceLevel > 0) { + throw new ShellSyntaxException("unmatched '{'"); + } // Deal with case where the braces are empty ... if (sb.length() == 0) { Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-02-01 06:49:07 UTC (rev 4953) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-02-01 09:15:46 UTC (rev 4954) @@ -222,7 +222,6 @@ case ';': case '&': case '|': - case '#': case ' ': case '\t': if (quoteChar == 0) { 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-02-01 06:49:07 UTC (rev 4953) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-01 09:15:46 UTC (rev 4954) @@ -117,8 +117,8 @@ <command>test</command> <runMode>AS_SCRIPT</runMode> <script>#!bjorne -A=5 -while expr $A != 0 ; do echo A is $A ; if expr $A = 2 ; then break ; fi ; A=`expr $A - 1`; done + A=5 + while expr $A != 0 ; do echo A is $A ; if expr $A = 2 ; then break ; fi ; A=`expr $A - 1`; done </script> <output>1 A is 5 @@ -135,4 +135,20 @@ </output> <rc>0</rc> </testSpec> + <testSpec> + <title>${...} expansions</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + echo A is $A + echo A is ${A} + echo A length is ${#A} + </script> + <output>A is cat +A is cat +A length is 3 +</output> + <rc>0</rc> + </testSpec> </testSpecs> \ 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: <ls...@us...> - 2009-02-01 23:22:11
|
Revision: 4964 http://jnode.svn.sourceforge.net/jnode/?rev=4964&view=rev Author: lsantha Date: 2009-02-01 21:50:49 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Fixed 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/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/CommandRunner.java trunk/shell/src/shell/org/jnode/shell/CommandShell.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/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/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/BjorneBuiltin.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompletable.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/BjorneShellPlugin.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/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/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/Redirection.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/SimpleCommandNode.java trunk/shell/src/shell/org/jnode/shell/bjorne/SourceBuiltin.java trunk/shell/src/shell/org/jnode/shell/command/AliasCommand.java trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java trunk/shell/src/shell/org/jnode/shell/command/ClassCommand.java trunk/shell/src/shell/org/jnode/shell/command/ClasspathCommand.java trunk/shell/src/shell/org/jnode/shell/command/CompileCommand.java trunk/shell/src/shell/org/jnode/shell/command/DateCommand.java trunk/shell/src/shell/org/jnode/shell/command/DisassembleCommand.java trunk/shell/src/shell/org/jnode/shell/command/EchoCommand.java trunk/shell/src/shell/org/jnode/shell/command/EnvCommand.java trunk/shell/src/shell/org/jnode/shell/command/ExitCommand.java trunk/shell/src/shell/org/jnode/shell/command/GcCommand.java trunk/shell/src/shell/org/jnode/shell/command/GrepCommand.java trunk/shell/src/shell/org/jnode/shell/command/HelpCommand.java trunk/shell/src/shell/org/jnode/shell/command/HistoryCommand.java trunk/shell/src/shell/org/jnode/shell/command/IsolateCommand.java trunk/shell/src/shell/org/jnode/shell/command/JavaCommand.java trunk/shell/src/shell/org/jnode/shell/command/KillCommand.java trunk/shell/src/shell/org/jnode/shell/command/LoadkeysCommand.java trunk/shell/src/shell/org/jnode/shell/command/LocaleCommand.java trunk/shell/src/shell/org/jnode/shell/command/MemoryCommand.java trunk/shell/src/shell/org/jnode/shell/command/NamespaceCommand.java trunk/shell/src/shell/org/jnode/shell/command/OnHeapCommand.java trunk/shell/src/shell/org/jnode/shell/command/PageCommand.java trunk/shell/src/shell/org/jnode/shell/command/RunCommand.java trunk/shell/src/shell/org/jnode/shell/command/SetCommand.java trunk/shell/src/shell/org/jnode/shell/command/SleepCommand.java trunk/shell/src/shell/org/jnode/shell/command/SyntaxCommand.java trunk/shell/src/shell/org/jnode/shell/command/TerminateCommand.java trunk/shell/src/shell/org/jnode/shell/command/ThreadCommand.java trunk/shell/src/shell/org/jnode/shell/command/ant/AntCommand.java trunk/shell/src/shell/org/jnode/shell/command/bsh/BshCommand.java trunk/shell/src/shell/org/jnode/shell/command/debug/DebugCommand.java trunk/shell/src/shell/org/jnode/shell/command/debug/RemoteOutputCommand.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/log4j/Log4jCommand.java trunk/shell/src/shell/org/jnode/shell/command/plugin/HaltCommand.java trunk/shell/src/shell/org/jnode/shell/command/plugin/PluginCommand.java trunk/shell/src/shell/org/jnode/shell/command/plugin/RebootCommand.java trunk/shell/src/shell/org/jnode/shell/command/posix/ExprCommand.java trunk/shell/src/shell/org/jnode/shell/command/posix/FalseCommand.java trunk/shell/src/shell/org/jnode/shell/command/posix/TrueCommand.java trunk/shell/src/shell/org/jnode/shell/command/posix/UnixTestCommand.java trunk/shell/src/shell/org/jnode/shell/command/system/CpuIDCommand.java trunk/shell/src/shell/org/jnode/shell/command/system/KdbCommand.java trunk/shell/src/shell/org/jnode/shell/command/system/LsIRQCommand.java trunk/shell/src/shell/org/jnode/shell/command/system/VmInfoCommand.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/SyntaxErrorException.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/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/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/ProcletCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletContext.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/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/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/MyDuhCommand.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.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/JNodeTestRunnerBase.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/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/TextContent.java trunk/shell/src/test/org/jnode/test/shell/help/DefaultHelpTest.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/RepeatedSyntaxTest.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 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/emu/org/jnode/emu/DeviceManager.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,6 +1,24 @@ /* - * $Id$ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * + * JNode.org + * 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.emu; import java.util.ArrayList; Modified: trunk/shell/src/emu/org/jnode/emu/Emu.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,6 +18,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.emu; import java.io.BufferedReader; Modified: trunk/shell/src/emu/org/jnode/emu/EmuException.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/EmuException.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/emu/org/jnode/emu/EmuException.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,3 +1,24 @@ +/* + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * + * JNode.org + * 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.emu; public class EmuException extends Exception { Modified: trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,7 +18,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.InputStream; Modified: trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,7 +18,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.driver.console.CompletionInfo; Modified: trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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.awt.event.KeyEvent; Modified: trunk/shell/src/shell/org/jnode/shell/Command.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/Command.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/Command.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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.InputStream; Modified: trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: CompletionInfo.java 2224 2006-01-01 12:49:03Z epr $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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.util.Collections; Modified: trunk/shell/src/shell/org/jnode/shell/CommandInfo.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 Modified: trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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.File; Modified: trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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; /* Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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.util.NoSuchElementException; Modified: trunk/shell/src/shell/org/jnode/shell/CommandRunner.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: CommandLine.java 3580 2007-11-03 20:31:24Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007 JNode.org + * 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 @@ -18,6 +18,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 gnu.java.security.action.InvokeAction; Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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.BufferedReader; Modified: trunk/shell/src/shell/org/jnode/shell/CommandThread.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandThread.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/CommandThread.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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; /** Modified: trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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; /** Modified: trunk/shell/src/shell/org/jnode/shell/Completable.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/Completable.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/Completable.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007 JNode.org + * 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 @@ -18,7 +18,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.driver.console.CompletionInfo; Modified: trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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 gnu.java.security.action.InvokeAction; Modified: trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007 JNode.org + * 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 @@ -18,7 +18,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.BufferedReader; Modified: trunk/shell/src/shell/org/jnode/shell/NoTokensAvailableException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/NoTokensAvailableException.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/NoTokensAvailableException.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007 JNode.org + * 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 @@ -18,6 +18,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 class NoTokensAvailableException extends RuntimeException { Modified: trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: FileArgument.java 3564 2007-10-20 20:11:31Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007 JNode.org + * 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 @@ -18,6 +18,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.File; Modified: trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2007 JNode.org + * 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 @@ -18,7 +18,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.FileInputStream; Modified: trunk/shell/src/shell/org/jnode/shell/Shell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/Shell.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/Shell.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 Modified: trunk/shell/src/shell/org/jnode/shell/ShellException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellException.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/ShellException.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 Modified: trunk/shell/src/shell/org/jnode/shell/ShellFailureException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellFailureException.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/ShellFailureException.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ShellException.java 2224 2006-01-01 12:49:03Z epr $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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; /** Modified: trunk/shell/src/shell/org/jnode/shell/ShellInvocationException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellInvocationException.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/ShellInvocationException.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ShellException.java 2224 2006-01-01 12:49:03Z epr $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,6 +18,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; /** Modified: trunk/shell/src/shell/org/jnode/shell/ShellManager.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellManager.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/ShellManager.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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; /** Modified: trunk/shell/src/shell/org/jnode/shell/ShellSyntaxException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellSyntaxException.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/ShellSyntaxException.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ShellManager.java 3571 2007-10-26 21:30:12Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,6 +18,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; /** Modified: trunk/shell/src/shell/org/jnode/shell/ShellUtils.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellUtils.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/ShellUtils.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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 javax.naming.NameNotFoundException; Modified: trunk/shell/src/shell/org/jnode/shell/SymbolSource.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/SymbolSource.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/SymbolSource.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: CommandLine.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,7 +18,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.util.Iterator; Modified: trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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; Modified: trunk/shell/src/shell/org/jnode/shell/ThreadExitListener.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ThreadExitListener.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/ThreadExitListener.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: ThreadCommandInvoker.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,7 +18,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; /** Modified: trunk/shell/src/shell/org/jnode/shell/alias/AliasManager.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/alias/AliasManager.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/alias/AliasManager.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 Modified: trunk/shell/src/shell/org/jnode/shell/alias/NoSuchAliasException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/alias/NoSuchAliasException.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/alias/NoSuchAliasException.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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.alias; import org.jnode.shell.ShellException; Modified: trunk/shell/src/shell/org/jnode/shell/alias/def/DefaultAliasManager.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/alias/def/DefaultAliasManager.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/alias/def/DefaultAliasManager.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -2,7 +2,7 @@ * $Id$ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,6 +18,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; import org.jnode.shell.CommandLine; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompletable.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompletable.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompletable.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,6 +18,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; import org.jnode.driver.console.CompletionInfo; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,6 +18,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; import static org.jnode.shell.bjorne.BjorneInterpreter.REDIR_CLOBBER; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,6 +18,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; import org.jnode.shell.ShellException; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,6 +18,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; import static org.jnode.shell.bjorne.BjorneToken.TOK_CLOBBER; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,6 +18,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; import static org.jnode.shell.bjorne.BjorneInterpreter.CMD_BRACE_GROUP; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneShellPlugin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneShellPlugin.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneShellPlugin.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: SystemHelpPlugin.java 2224 2006-01-01 12:49:03Z epr $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2003-2006 JNode.org + * 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 @@ -18,7 +18,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; import javax.naming.NamingException; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,6 +18,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; import org.jnode.shell.CommandLine; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,6 +18,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; import static org.jnode.shell.bjorne.BjorneToken.RULE_1_CONTEXT; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BreakBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BreakBuiltin.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BreakBuiltin.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,6 +18,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; import java.util.Iterator; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-02-01 21:33:54 UTC (rev 4963) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-02-01 21:50:49 UTC (rev 4964) @@ -1,8 +1,8 @@ /* - * $Id: Command.java 3772 2008-02-10 15:02:53Z lsantha $ + * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ * * JNode.org - * Copyright (C) 2007-2008 JNode.org + * 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 @@ -18,6 +18,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; import org.jnode.shell.ShellException; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CaseItemNode.java ==============================================... [truncated message content] |
From: <ls...@us...> - 2009-02-02 09:09:46
|
Revision: 4977 http://jnode.svn.sourceforge.net/jnode/?rev=4977&view=rev Author: lsantha Date: 2009-02-02 09:09:41 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Fixed header. 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/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/CommandRunner.java trunk/shell/src/shell/org/jnode/shell/CommandShell.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/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/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/BjorneBuiltin.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompletable.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/BjorneShellPlugin.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/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/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/Redirection.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/SimpleCommandNode.java trunk/shell/src/shell/org/jnode/shell/bjorne/SourceBuiltin.java trunk/shell/src/shell/org/jnode/shell/command/AliasCommand.java trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java trunk/shell/src/shell/org/jnode/shell/command/ClassCommand.java trunk/shell/src/shell/org/jnode/shell/command/ClasspathCommand.java trunk/shell/src/shell/org/jnode/shell/command/CompileCommand.java trunk/shell/src/shell/org/jnode/shell/command/DateCommand.java trunk/shell/src/shell/org/jnode/shell/command/DisassembleCommand.java trunk/shell/src/shell/org/jnode/shell/command/EchoCommand.java trunk/shell/src/shell/org/jnode/shell/command/EnvCommand.java trunk/shell/src/shell/org/jnode/shell/command/ExitCommand.java trunk/shell/src/shell/org/jnode/shell/command/GcCommand.java trunk/shell/src/shell/org/jnode/shell/command/GrepCommand.java trunk/shell/src/shell/org/jnode/shell/command/HelpCommand.java trunk/shell/src/shell/org/jnode/shell/command/HistoryCommand.java trunk/shell/src/shell/org/jnode/shell/command/IsolateCommand.java trunk/shell/src/shell/org/jnode/shell/command/JavaCommand.java trunk/shell/src/shell/org/jnode/shell/command/KillCommand.java trunk/shell/src/shell/org/jnode/shell/command/LoadkeysCommand.java trunk/shell/src/shell/org/jnode/shell/command/LocaleCommand.java trunk/shell/src/shell/org/jnode/shell/command/MemoryCommand.java trunk/shell/src/shell/org/jnode/shell/command/NamespaceCommand.java trunk/shell/src/shell/org/jnode/shell/command/OnHeapCommand.java trunk/shell/src/shell/org/jnode/shell/command/PageCommand.java trunk/shell/src/shell/org/jnode/shell/command/RunCommand.java trunk/shell/src/shell/org/jnode/shell/command/SetCommand.java trunk/shell/src/shell/org/jnode/shell/command/SleepCommand.java trunk/shell/src/shell/org/jnode/shell/command/SyntaxCommand.java trunk/shell/src/shell/org/jnode/shell/command/TerminateCommand.java trunk/shell/src/shell/org/jnode/shell/command/ThreadCommand.java trunk/shell/src/shell/org/jnode/shell/command/ant/AntCommand.java trunk/shell/src/shell/org/jnode/shell/command/bsh/BshCommand.java trunk/shell/src/shell/org/jnode/shell/command/debug/DebugCommand.java trunk/shell/src/shell/org/jnode/shell/command/debug/RemoteOutputCommand.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/log4j/Log4jCommand.java trunk/shell/src/shell/org/jnode/shell/command/plugin/HaltCommand.java trunk/shell/src/shell/org/jnode/shell/command/plugin/PluginCommand.java trunk/shell/src/shell/org/jnode/shell/command/plugin/RebootCommand.java trunk/shell/src/shell/org/jnode/shell/command/posix/ExprCommand.java trunk/shell/src/shell/org/jnode/shell/command/posix/FalseCommand.java trunk/shell/src/shell/org/jnode/shell/command/posix/TrueCommand.java trunk/shell/src/shell/org/jnode/shell/command/posix/UnixTestCommand.java trunk/shell/src/shell/org/jnode/shell/command/system/CpuIDCommand.java trunk/shell/src/shell/org/jnode/shell/command/system/KdbCommand.java trunk/shell/src/shell/org/jnode/shell/command/system/LsIRQCommand.java trunk/shell/src/shell/org/jnode/shell/command/system/VmInfoCommand.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/SyntaxErrorException.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/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/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/ProcletCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletContext.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/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/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/MyDuhCommand.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.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/JNodeTestRunnerBase.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/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/TextContent.java trunk/shell/src/test/org/jnode/test/shell/help/DefaultHelpTest.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/RepeatedSyntaxTest.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 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/emu/org/jnode/emu/DeviceManager.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/emu/org/jnode/emu/Emu.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/emu/org/jnode/emu/EmuException.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/EmuException.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/emu/org/jnode/emu/EmuException.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/AbstractCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/Command.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/Command.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/Command.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/CommandCompletions.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/CommandInfo.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/CommandInfo.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/CommandRunner.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/CommandThread.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandThread.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/CommandThread.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/CommandThreadImpl.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/Completable.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/Completable.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/Completable.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/NoTokensAvailableException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/NoTokensAvailableException.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/NoTokensAvailableException.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/Shell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/Shell.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/Shell.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/ShellException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellException.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/ShellException.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/ShellFailureException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellFailureException.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/ShellFailureException.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/ShellInvocationException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellInvocationException.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/ShellInvocationException.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/ShellManager.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellManager.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/ShellManager.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/ShellSyntaxException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellSyntaxException.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/ShellSyntaxException.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/ShellUtils.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellUtils.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/ShellUtils.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/SymbolSource.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/SymbolSource.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/SymbolSource.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/ThreadExitListener.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ThreadExitListener.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/ThreadExitListener.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/alias/AliasManager.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/alias/AliasManager.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/alias/AliasManager.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/alias/NoSuchAliasException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/alias/NoSuchAliasException.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/alias/NoSuchAliasException.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/alias/def/DefaultAliasManager.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/alias/def/DefaultAliasManager.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/alias/def/DefaultAliasManager.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompletable.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompletable.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneCompletable.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneShellPlugin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneShellPlugin.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneShellPlugin.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BreakBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BreakBuiltin.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BreakBuiltin.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CaseItemNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/CaseItemNode.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/CaseItemNode.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ColonBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ColonBuiltin.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ColonBuiltin.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/CommandNode.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/CommandNode.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ContinueBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ContinueBuiltin.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ContinueBuiltin.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/Redirection.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/Redirection.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/Redirection.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/RedirectionNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/RedirectionNode.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/RedirectionNode.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ReturnBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ReturnBuiltin.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ReturnBuiltin.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/SetBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/SetBuiltin.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/SetBuiltin.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/SourceBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/SourceBuiltin.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/SourceBuiltin.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/AliasCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/AliasCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/AliasCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/ClassCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/ClassCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/ClassCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/ClasspathCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/ClasspathCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/ClasspathCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/CompileCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/CompileCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/CompileCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/DateCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/DateCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/DateCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/DisassembleCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/DisassembleCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/DisassembleCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/EchoCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/EchoCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/EchoCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/EnvCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/EnvCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/EnvCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/ExitCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/ExitCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/ExitCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/GcCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/GcCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/GcCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/GrepCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/GrepCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/GrepCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/HelpCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/HelpCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/HelpCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/HistoryCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/HistoryCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/HistoryCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/IsolateCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/IsolateCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/IsolateCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @@ /* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ + * $Id$ * - * JNode.org * Copyright (C) 2003-2009 JNode.org * * This library is free software; you can redistribute it and/or modify it Modified: trunk/shell/src/shell/org/jnode/shell/command/JavaCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/JavaCommand.java 2009-02-02 08:43:50 UTC (rev 4976) +++ trunk/shell/src/shell/org/jnode/shell/command/JavaCommand.java 2009-02-02 09:09:41 UTC (rev 4977) @@ -1,7 +1,6 @... [truncated message content] |
From: <cr...@us...> - 2009-02-02 11:01:03
|
Revision: 4979 http://jnode.svn.sourceforge.net/jnode/?rev=4979&view=rev Author: crawley Date: 2009-02-02 11:00:56 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Implemented S{param<op>word} expansions for <op> '?', ':?', '-' and ':-' 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/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-02-02 09:23:07 UTC (rev 4978) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneBuiltin.java 2009-02-02 11:00:56 UTC (rev 4979) @@ -20,6 +20,7 @@ package org.jnode.shell.bjorne; +import org.jnode.shell.Command; import org.jnode.shell.CommandLine; import org.jnode.shell.ShellException; @@ -29,7 +30,7 @@ BjorneContext context) throws ShellException; void error(String msg, BjorneContext context) { - context.resolvePrintStream(context.getStream(2)).println(msg); + context.resolvePrintStream(context.getStream(Command.STD_ERR)).println(msg); } } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-02 09:23:07 UTC (rev 4978) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-02 11:00:56 UTC (rev 4979) @@ -547,7 +547,7 @@ return sb; } - private String dollarExpansion(CharIterator ci, char quote) throws ShellSyntaxException { + private String dollarExpansion(CharIterator ci, char quote) throws ShellException { int ch = ci.nextCh(); switch (ch) { case -1: @@ -587,7 +587,7 @@ } } - private String dollarBraceExpansion(CharIterator ci) throws ShellSyntaxException { + private String dollarBraceExpansion(CharIterator ci) throws ShellException { // Scan to the '}' that matches the '${' StringBuffer sb = new StringBuffer(); int braceLevel = 1; @@ -722,9 +722,10 @@ case HYPHEN: case HASH: case PERCENT: + i++; break; default: - i++; + i += 2; break; } // Extract the word @@ -739,6 +740,26 @@ return (value != null) ? value : ""; case PREHASH: return (value != null) ? Integer.toString(value.length()) : "0"; + case HYPHEN: + return (value == null) ? word : value; + case COLONHYPHEN: + return (value == null || value.length() == 0) ? word : value; + case QUERY: + if (value == null) { + String msg = word.length() > 0 ? word : (parameter + " is unset"); + resolvePrintStream(getStream(Command.STD_ERR)).println(msg); + throw new BjorneControlException(BjorneInterpreter.BRANCH_EXIT, 1); + } else { + return value; + } + case COLONQUERY: + if (value == null || value.length() == 0) { + String msg = word.length() > 0 ? word : (parameter + " is unset or null"); + resolvePrintStream(getStream(Command.STD_ERR)).println(msg); + throw new BjorneControlException(BjorneInterpreter.BRANCH_EXIT, 1); + } else { + return value; + } default: throw new ShellFailureException("not implemented"); } 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-02-02 09:23:07 UTC (rev 4978) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-02 11:00:56 UTC (rev 4979) @@ -141,14 +141,90 @@ <runMode>AS_SCRIPT</runMode> <script>#!bjorne A=cat + B= echo A is $A echo A is ${A} + echo B is $B + echo B is ${B} + echo X is $X + echo X is ${X} echo A length is ${#A} + echo B length is ${#B} + echo X length is ${#X} + echo A :- dog is ${A:-dog} + echo B :- dog is ${B:-dog} + echo X :- dog is ${X:-dog} + echo A - dog is ${A-dog} + echo B - dog is ${B-dog} + echo X - dog is ${X-dog} </script> <output>A is cat A is cat +B is +B is +X is +X is A length is 3 +B length is 0 +X length is 0 +A :- dog is cat +B :- dog is dog +X :- dog is dog +A - dog is cat +B - dog is +X - dog is dog </output> <rc>0</rc> </testSpec> + <testSpec> + <title>${..?..} expansions #1</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B= + echo A :? dog is ${A:?dog} + echo B :? dog is ${B:?dog} + echo X :? dog is ${X:?dog} + </script> + <output>A :? dog is cat +</output> + <error>dog +</error> + <rc>1</rc> + </testSpec> + <testSpec> + <title>${..?..} expansions #2</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B= + echo A :? dog is ${A:?dog} + echo X :? dog is ${X:?dog} + </script> + <output>A :? dog is cat +</output> + <error>dog +</error> + <rc>1</rc> + </testSpec> + <testSpec> + <title>${..?..} expansions #3</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B= + echo A ? dog is ${A?dog} + echo B ? dog is ${B?dog} + echo X ? dog is ${X?dog} + </script> + <output>A ? dog is cat +B ? dog is +</output> + <error>dog +</error> + <rc>1</rc> + </testSpec> </testSpecs> \ 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-02-02 12:05:38
|
Revision: 4981 http://jnode.svn.sourceforge.net/jnode/?rev=4981&view=rev Author: crawley Date: 2009-02-02 12:03:37 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Implemented ${param+word} and ${param:+word} 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-02-02 11:53:36 UTC (rev 4980) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-02 12:03:37 UTC (rev 4981) @@ -741,6 +741,10 @@ return (value == null) ? word : value; case COLONHYPHEN: return (value == null || value.length() == 0) ? word : value; + case PLUS: + return (value == null) ? "" : word; + case COLONPLUS: + return (value == null || value.length() == 0) ? "" : word; case QUERY: if (value == null) { String msg = word.length() > 0 ? word : (parameter + " is unset"); 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-02-02 11:53:36 UTC (rev 4980) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-02 12:03:37 UTC (rev 4981) @@ -163,6 +163,18 @@ echo A - null is ${A-} echo B - null is ${B-} echo X - null is ${X-} + echo A :+ dog is ${A:+dog} + echo B :+ dog is ${B:+dog} + echo X :+ dog is ${X:+dog} + echo A + dog is ${A+dog} + echo B + dog is ${B+dog} + echo X + dog is ${X+dog} + echo A :+ null is ${A:+} + echo B :+ null is ${B:+} + echo X :+ null is ${X:+} + echo A + null is ${A+} + echo B + null is ${B+} + echo X + null is ${X+} </script> <output>A is cat A is cat @@ -185,6 +197,18 @@ A - null is cat B - null is X - null is +A :+ dog is dog +B :+ dog is +X :+ dog is +A + dog is dog +B + dog is dog +X + dog is +A :+ null is +B :+ null is +X :+ null is +A + null is +B + null is +X + null is </output> <rc>0</rc> </testSpec> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-02 12:22:02
|
Revision: 4980 http://jnode.svn.sourceforge.net/jnode/?rev=4980&view=rev Author: crawley Date: 2009-02-02 11:53:36 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Implement ${param=word} and ${param:=word} 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-02-02 11:00:56 UTC (rev 4979) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-02 11:53:36 UTC (rev 4980) @@ -729,9 +729,6 @@ break; } // Extract the word - if (i >= sb.length()) { - throw new ShellSyntaxException("bad substitution"); - } word = sb.substring(i); } String value = variable(parameter); @@ -760,6 +757,20 @@ } else { return value; } + case EQUALS: + if (value == null) { + setVariable(parameter, word); + return word; + } else { + return value; + } + case COLONEQUALS: + if (value == null || value.length() == 0) { + setVariable(parameter, word); + return word; + } else { + return value; + } default: throw new ShellFailureException("not implemented"); } 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-02-02 11:00:56 UTC (rev 4979) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-02 11:53:36 UTC (rev 4980) @@ -157,6 +157,12 @@ echo A - dog is ${A-dog} echo B - dog is ${B-dog} echo X - dog is ${X-dog} + echo A :- null is ${A:-} + echo B :- null is ${B:-} + echo X :- null is ${X:-} + echo A - null is ${A-} + echo B - null is ${B-} + echo X - null is ${X-} </script> <output>A is cat A is cat @@ -173,6 +179,12 @@ A - dog is cat B - dog is X - dog is dog +A :- null is cat +B :- null is +X :- null is +A - null is cat +B - null is +X - null is </output> <rc>0</rc> </testSpec> @@ -227,4 +239,101 @@ </error> <rc>1</rc> </testSpec> + <testSpec> + <title>${..?..} expansions #4</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B= + echo A :? null is ${A:?} + echo B :? null is ${B:?} + echo X :? null is ${X:?} + </script> + <output>A :? null is cat +</output> + <error>B is unset or null +</error> + <rc>1</rc> + </testSpec> + <testSpec> + <title>${..?..} expansions #5</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B= + echo A :? null is ${A:?} + echo X :? null is ${X:?} + </script> + <output>A :? null is cat +</output> + <error>X is unset or null +</error> + <rc>1</rc> + </testSpec> + <testSpec> + <title>${..?..} expansions #6</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B= + echo A ? null is ${A?} + echo B ? null is ${B?} + echo X ? null is ${X?} + </script> + <output>A ? null is cat +B ? null is +</output> + <error>X is unset +</error> + <rc>1</rc> + </testSpec> + <testSpec> + <title>${..=..} expansions</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B= + echo A := dog is ${A:=dog} + echo $A + echo B := dog is ${B:=dog} + echo $B + echo X := dog is ${X:=dog} + echo $X + </script> + <output>A := dog is cat +cat +B := dog is dog +dog +X := dog is dog +dog +</output> + <rc>0</rc> + </testSpec> + <testSpec> + <title>${..=..} expansions #2</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B= + echo A = dog is ${A=dog} + echo $A + echo B = dog is ${B=dog} + echo $B + echo X = dog is ${X=dog} + echo $X + </script> + <output>A = dog is cat +cat +B = dog is + +X = dog is dog +dog +</output> + <rc>0</rc> + </testSpec> </testSpecs> \ 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-02-04 13:19:45
|
Revision: 4997 http://jnode.svn.sourceforge.net/jnode/?rev=4997&view=rev Author: crawley Date: 2009-02-04 13:19:41 +0000 (Wed, 04 Feb 2009) Log Message: ----------- Added hooks to shell for multi-line commands (with continuation prompts). Implemented hooks in bjorne parser, and fixed various latent bugs with handling of newlines. 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/bjorne/BjorneInterpreter.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml Added Paths: ----------- trunk/shell/src/shell/org/jnode/shell/IncompleteCommandException.java Modified: trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-02-02 19:44:07 UTC (rev 4996) +++ trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-02-04 13:19:41 UTC (rev 4997) @@ -113,4 +113,18 @@ * @throws ShellException */ boolean help(CommandShell shell, String partial, PrintWriter pw) throws ShellException; + + /** + * This method should <code>true</code> if the interpreter supports continuation lines. If so, + * it should throw IncompleteCommandException if it is expecting more input from the + * user. The shell will respond by reading the next line from the user, appending it + * to the previous input, and attempting to interpret the line again. Obviously, the + * interpreter needs to be side-effect free prior to throwing the exception. + * <p> + * If this method returns <code>false</code>, the interpreter will treat IncompleteCommandException + * as a regular ShellSyntaxException. + * + * @return <code>true</code> if this interpreter supports continuation lines. + */ + boolean supportsMultilineCommands(); } Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-02-02 19:44:07 UTC (rev 4996) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-02-04 13:19:41 UTC (rev 4997) @@ -335,9 +335,32 @@ clearEof(); outPW.print(prompt()); readingCommand = true; - String line = readInputLine().trim(); + String line = readInputLine(); if (line.length() > 0) { - runCommand(line, true, this.interpreter); + boolean done = false; + do { + try { + runCommand(line, true, this.interpreter); + done = true; + } catch (IncompleteCommandException ex) { + String continuation = null; + if (this.interpreter.supportsMultilineCommands()) { + String prompt = ex.getPrompt(); + if (prompt != null) { + outPW.print(prompt); + } + continuation = readInputLine(); + } + if (continuation == null) { + diagnose(ex); + break; + } else { + line = line + "\n" + continuation; + } + } catch (ShellException ex) { + diagnose(ex); + } + } while (!done); } if (VmSystem.isShuttingDown()) { @@ -351,6 +374,47 @@ } } + private void diagnose(ShellException ex) { + Throwable cause = ex.getCause(); + // Try to turn this into something that is moderately intelligible + // for the common cases ... + if (cause != null) { + errPW.println(ex.getMessage()); + if (cause instanceof CommandSyntaxException) { + List<Context> argErrors = ((CommandSyntaxException) cause).getArgErrors(); + if (argErrors != null) { + // The parser can produce many errors as each of the alternatives + // in the tree are explored. The following assumes that errors + // produced when we get farthest along in the token stream are most + // likely to be the "real" errors. + int rightmostPos = 0; + for (Context context : argErrors) { + if (context.sourcePos > rightmostPos) { + rightmostPos = context.sourcePos; + } + } + for (Context context : argErrors) { + if (context.sourcePos < rightmostPos) { + continue; + } + if (context.token != null) { + errPW.println(" " + context.exception.getMessage() + ": " + + context.token.text); + } else { + errPW.println(" " + context.exception.getMessage() + ": " + + context.syntax.format()); + } + } + } + } else { + errPW.println(cause.getMessage()); + } + } else { + errPW.println("Shell exception: " + ex.getMessage()); + } + stackTrace(ex); + } + public void configureShell() { try { ShellUtils.getShellManager().registerShell(this); @@ -465,7 +529,7 @@ } private int runCommand(String cmdLineStr, boolean interactive, - CommandInterpreter interpreter) { + CommandInterpreter interpreter) throws ShellException { if (interactive) { clearEof(); readingCommand = false; @@ -473,50 +537,7 @@ // for input completion applicationHistory.set(new InputHistory()); } - int rc = 0; - try { - rc = interpreter.interpret(this, cmdLineStr); - } catch (ShellException ex) { - Throwable cause = ex.getCause(); - // Try to turn this into something that is moderately intelligible - // for the common cases ... - if (cause != null) { - errPW.println(ex.getMessage()); - if (cause instanceof CommandSyntaxException) { - List<Context> argErrors = ((CommandSyntaxException) cause).getArgErrors(); - if (argErrors != null) { - // The parser can produce many errors as each of the alternatives - // in the tree are explored. The following assumes that errors - // produced when we get farthest along in the token stream are most - // likely to be the "real" errors. - int rightmostPos = 0; - for (Context context : argErrors) { - if (context.sourcePos > rightmostPos) { - rightmostPos = context.sourcePos; - } - } - for (Context context : argErrors) { - if (context.sourcePos < rightmostPos) { - continue; - } - if (context.token != null) { - errPW.println(" " + context.exception.getMessage() + ": " + - context.token.text); - } else { - errPW.println(" " + context.exception.getMessage() + ": " + - context.syntax.format()); - } - } - } - } else { - errPW.println(cause.getMessage()); - } - } else { - errPW.println("Shell exception: " + ex.getMessage()); - } - rc = -1; - stackTrace(ex); - } + int rc = interpreter.interpret(this, cmdLineStr); 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-02-02 19:44:07 UTC (rev 4996) +++ trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-02-04 13:19:41 UTC (rev 4997) @@ -139,6 +139,11 @@ } @Override + public boolean supportsMultilineCommands() { + return false; + } + + @Override public int interpret(CommandShell shell, File file) throws ShellException { try { return interpret(shell, new FileReader(file)); Added: trunk/shell/src/shell/org/jnode/shell/IncompleteCommandException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/IncompleteCommandException.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/IncompleteCommandException.java 2009-02-04 13:19:41 UTC (rev 4997) @@ -0,0 +1,36 @@ +/* + * $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 class IncompleteCommandException extends ShellSyntaxException { + + private static final long serialVersionUID = 3710602404013731870L; + + private final String prompt; + + public IncompleteCommandException(String msg, String prompt) { + super(msg); + this.prompt = prompt; + } + + public String getPrompt() { + return prompt; + } +} Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-02 19:44:07 UTC (rev 4996) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-04 13:19:41 UTC (rev 4997) @@ -49,6 +49,7 @@ import org.jnode.shell.CommandShell; import org.jnode.shell.CommandThread; import org.jnode.shell.Completable; +import org.jnode.shell.IncompleteCommandException; import org.jnode.shell.ShellException; import org.jnode.shell.ShellFailureException; import org.jnode.shell.ShellSyntaxException; @@ -188,7 +189,7 @@ public Completable parsePartial(CommandShell shell, String partial) throws ShellSyntaxException { bindShell(shell); BjorneTokenizer tokens = new BjorneTokenizer(partial); - final CommandNode tree = new BjorneParser(tokens).parse(); + final CommandNode tree = new BjorneParser(tokens, "> ").parse(); if (tree instanceof BjorneCompletable) { return new Completable() { @Override @@ -228,7 +229,7 @@ myContext.setStream(1, new CommandOutput(capture), true); } BjorneTokenizer tokens = new BjorneTokenizer(command); - CommandNode tree = new BjorneParser(tokens).parse(); + CommandNode tree = new BjorneParser(tokens, "> ").parse(); if (tree == null) { // An empty command line return 0; @@ -242,6 +243,11 @@ } return tree.execute((BjorneContext) myContext); } + + @Override + public boolean supportsMultilineCommands() { + return true; + } @Override public int interpret(CommandShell shell, Reader reader) throws ShellException { @@ -251,24 +257,34 @@ String line; int rc = 0; while ((line = br.readLine()) != null) { - try { - rc = interpret(shell, line, null, false); - } catch (BjorneControlException ex) { - switch (ex.getControl()) { + 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"); + "'break' has been executed in an inappropriate context"); case BjorneInterpreter.BRANCH_CONTINUE: throw new ShellSyntaxException( - "'continue' has been executed in an inappropriate context"); + "'continue' has been executed in an inappropriate context"); case BjorneInterpreter.BRANCH_RETURN: throw new ShellSyntaxException( - "'return' has been executed in an inappropriate context"); + "'return' has been executed in an inappropriate context"); + } + } catch (IncompleteCommandException ex) { + String continuation = br.readLine(); + if (continuation == null) { + throw ex; + } + line = line + "\n" + continuation; } - } + } while (!done); } return rc; } catch (IOException ex) { Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-02-02 19:44:07 UTC (rev 4996) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-02-04 13:19:41 UTC (rev 4997) @@ -82,14 +82,18 @@ import java.util.LinkedList; import java.util.List; +import org.jnode.shell.IncompleteCommandException; import org.jnode.shell.ShellFailureException; import org.jnode.shell.ShellSyntaxException; public class BjorneParser { private final BjorneTokenizer tokens; + + private final String continuationPrompt; - public BjorneParser(BjorneTokenizer tokens) { + public BjorneParser(BjorneTokenizer tokens, String continuationPrompt) { this.tokens = tokens; + this.continuationPrompt = continuationPrompt; } /** @@ -174,6 +178,7 @@ } private CommandNode parseOptAndOr() throws ShellSyntaxException { + skipLineBreaks(); switch (tokens.peek(RULE_1_CONTEXT).getTokenType()) { case TOK_LBRACE: case TOK_LPAREN: @@ -349,9 +354,9 @@ return null; } tokens.next(); - if (tokens.next().getTokenType() != TOK_RPAREN) { - throw new ShellSyntaxException( - "expected matching ')' in function_definition"); + int tt = tokens.next().getTokenType(); + if (tt != TOK_RPAREN) { + syntaxError("expected matching ')' in function_definition", tt); } skipLineBreaks(); return new FunctionDefinitionNode(fname, parseFunctionBody()); @@ -412,8 +417,8 @@ io = token; token = tokens.next(); } - int tokenType = token.getTokenType(); - switch (tokenType) { + int tt = token.getTokenType(); + switch (tt) { case TOK_LESS: case TOK_GREAT: case TOK_DGREAT: @@ -422,15 +427,17 @@ case TOK_LESSGREAT: case TOK_CLOBBER: arg = tokens.next(); - if (arg.getTokenType() != TOK_WORD) { - throw new ShellSyntaxException("expected a filename after " + token); + tt = arg.getTokenType(); + if (tt != TOK_WORD) { + syntaxError("expected a filename after " + token, tt); } break; case TOK_DLESS: case TOK_DLESSDASH: arg = tokens.next(); + tt = arg.getTokenType(); if (arg.getTokenType() != TOK_WORD) { - throw new ShellSyntaxException("expected a here-end marker " + token); + syntaxError("expected a here-end marker " + token, tt); } // TODO ... need to grab the HERE document ... break; @@ -439,7 +446,7 @@ } // (The corresponding token type and redirection type values are the // same ...) - return new RedirectionNode(tokenType, io, arg); + return new RedirectionNode(tt, io, arg); } private RedirectionNode[] parseOptRedirects() throws ShellSyntaxException { @@ -472,8 +479,9 @@ private CommandNode parseSubshell() throws ShellSyntaxException { tokens.next(); CommandNode compoundList = parseCompoundList(); - if (tokens.next().getTokenType() != TOK_RPAREN) { - throw new ShellSyntaxException("expected ')'"); + int tt = tokens.next().getTokenType(); + if (tt != TOK_RPAREN) { + syntaxError("expected ')'", tt); } compoundList.setNodeType(CMD_SUBSHELL); return compoundList; @@ -486,12 +494,14 @@ LOOP: while (command != null) { commands.add(command); - skipLineBreaks(); switch (tokens.peek().getTokenType()) { case TOK_SEMI: break; + case TOK_END_OF_LINE: + break; case TOK_AMP: command.setFlag(FLAG_ASYNC); + break; default: break LOOP; } @@ -504,8 +514,9 @@ private CommandNode parseBraceGroup() throws ShellSyntaxException { tokens.next(); CommandNode compoundList = parseCompoundList(); - if (tokens.peek().getTokenType() != TOK_RBRACE) { - throw new ShellSyntaxException("expected '}'"); + int tt = tokens.peek().getTokenType(); + if (tt != TOK_RBRACE) { + syntaxError("expected '}'", tt); } compoundList.setNodeType(CMD_BRACE_GROUP); return compoundList; @@ -516,8 +527,9 @@ BjorneToken word = tokens.next(); List<CaseItemNode> caseItems = new LinkedList<CaseItemNode>(); skipLineBreaks(); - if (tokens.next(RULE_6_CONTEXT).getTokenType() != TOK_IN) { - throw new ShellSyntaxException("expected 'in' in case_clause"); + int tt = tokens.next(RULE_6_CONTEXT).getTokenType(); + if (tt != TOK_IN) { + syntaxError("expected 'in' in case_clause", tt); } skipLineBreaks(); BjorneToken token = tokens.peek(RULE_1_CONTEXT); @@ -525,13 +537,13 @@ caseItems.add(parseCaseItem()); skipLineBreaks(); token = tokens.peek(RULE_1_CONTEXT); - if (token.getTokenType() == TOK_DSEMI) { + tt = token.getTokenType(); + if (tt == TOK_DSEMI) { tokens.next(); skipLineBreaks(); token = tokens.peek(RULE_1_CONTEXT); - } else if (token.getTokenType() != TOK_ESAC) { - throw new ShellSyntaxException( - "expected ';;' or 'esac' after case_item"); + } else if (tt != TOK_ESAC) { + syntaxError("expected ';;' or 'esac' after case_item", tt); } } tokens.next(); @@ -548,9 +560,9 @@ token = tokens.next(); } BjorneToken[] pattern = parsePattern(); - if (tokens.next().getTokenType() != TOK_RPAREN) { - throw new ShellSyntaxException( - "expected ')' after pattern in case_item"); + int tt = tokens.next().getTokenType(); + if (tt != TOK_RPAREN) { + syntaxError("expected ')' after pattern in case_item", tt); } CommandNode body = null; skipLineBreaks(); @@ -567,9 +579,9 @@ private BjorneToken[] parsePattern() throws ShellSyntaxException { List<BjorneToken> pattern = new LinkedList<BjorneToken>(); while (true) { - BjorneToken token = tokens.next(); - if (token.getTokenType() != TOK_WORD) { - throw new ShellSyntaxException("expected WORD in pattern"); + int tt = tokens.next().getTokenType(); + if (tt != TOK_WORD) { + syntaxError("expected WORD in pattern", tt); } if (tokens.peek().getTokenType() != TOK_BAR) { break; @@ -582,8 +594,9 @@ private ForCommandNode parseForCommand() throws ShellSyntaxException { tokens.next(); BjorneToken var = tokens.next(RULE_5_CONTEXT); - if (var.getTokenType() != TOK_NAME) { - throw new ShellSyntaxException("expected a NAME following 'for'"); + int tt = var.getTokenType(); + if (tt != TOK_NAME) { + syntaxError("expected a NAME following 'for'", tt); } skipLineBreaks(); List<BjorneToken> words = new LinkedList<BjorneToken>(); @@ -596,10 +609,10 @@ word = tokens.peek(); } if (words.isEmpty()) { - throw new ShellSyntaxException( - "expected a wordlist following 'in'"); + syntaxError("expected a wordlist following 'in'", word.getTokenType()); } - switch (tokens.peek().getTokenType()) { + tt = tokens.peek().getTokenType(); + switch (tt) { case TOK_SEMI: tokens.next(); skipLineBreaks(); @@ -608,7 +621,7 @@ skipLineBreaks(); break; default: - throw new ShellSyntaxException("expected a ';' following wordlist"); + syntaxError("expected a ';' following wordlist", tt); } } return new ForCommandNode(var, @@ -616,13 +629,16 @@ } private CommandNode parseDoGroup() throws ShellSyntaxException { - BjorneToken token = tokens.next(RULE_1_CONTEXT); - if (token.getTokenType() != TOK_DO) { - throw new ShellSyntaxException("expected the 'do' of a do_group"); + skipLineBreaks(); + int tt = tokens.next(RULE_1_CONTEXT).getTokenType(); + if (tt != TOK_DO) { + syntaxError("expected the 'do' of a do_group", tt); } CommandNode body = parseCompoundList(); - if (tokens.next(RULE_1_CONTEXT).getTokenType() != TOK_DONE) { - throw new ShellSyntaxException("expected a command or 'done'"); + skipLineBreaks(); + tt = tokens.next(RULE_1_CONTEXT).getTokenType(); + if (tt != TOK_DONE) { + syntaxError("expected a command or 'done'", tt); } return body; } @@ -644,23 +660,30 @@ private IfCommandNode parseIfCommand() throws ShellSyntaxException { tokens.next(); CommandNode cond = parseCompoundList(); - if (tokens.next(RULE_1_CONTEXT).getTokenType() != TOK_THEN) { - throw new ShellSyntaxException("expected a 'then' in if_clause"); + skipLineBreaks(); + int tt = tokens.next(RULE_1_CONTEXT).getTokenType(); + if (tt != TOK_THEN) { + syntaxError("expected a 'then' in if_clause", tt); } CommandNode thenPart = parseCompoundList(); CommandNode elsePart = parseOptElsePart(); - if (tokens.next(RULE_1_CONTEXT).getTokenType() != TOK_FI) { - throw new ShellSyntaxException("expected an 'elif', 'else' or 'fi'"); + skipLineBreaks(); + tt = tokens.next(RULE_1_CONTEXT).getTokenType(); + if (tt != TOK_FI) { + syntaxError("expected an 'elif', 'else' or 'fi'", tt); } return new IfCommandNode(CMD_IF, cond, thenPart, elsePart); } private CommandNode parseOptElsePart() throws ShellSyntaxException { + skipLineBreaks(); switch (tokens.next(RULE_1_CONTEXT).getTokenType()) { case TOK_ELIF: CommandNode cond = parseCompoundList(); - if (tokens.next(RULE_1_CONTEXT).getTokenType() != TOK_THEN) { - throw new ShellSyntaxException("expected a 'then' in else_part"); + skipLineBreaks(); + int tt = tokens.next(RULE_1_CONTEXT).getTokenType(); + if (tt != TOK_THEN) { + syntaxError("expected a 'then' in else_part", tt); } return new IfCommandNode(CMD_ELIF, cond, parseCompoundList(), parseOptElsePart()); @@ -671,6 +694,15 @@ return null; } } + + private void syntaxError(String msg, int tt) throws ShellSyntaxException { + if (tt == TOK_END_OF_STREAM) { + throw new IncompleteCommandException(msg, continuationPrompt); + } else { + System.err.println("tt is " + tt); + throw new ShellSyntaxException(msg); + } + } private void skipLineBreaks() { while (tokens.peek().getTokenType() == TOK_END_OF_LINE) { Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java 2009-02-02 19:44:07 UTC (rev 4996) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java 2009-02-04 13:19:41 UTC (rev 4997) @@ -31,7 +31,7 @@ private static final boolean DEBUG = true; public void testParser() { - new BjorneParser(new BjorneTokenizer("")); + new BjorneParser(new BjorneTokenizer(""), null); } public void test1() throws ShellException { @@ -147,7 +147,7 @@ } private String doTest(String input) throws ShellException { - BjorneParser p = new BjorneParser(new BjorneTokenizer(input, DEBUG)); + BjorneParser p = new BjorneParser(new BjorneTokenizer(input, DEBUG), null); String res = p.parse().toString(); if (DEBUG) { System.err.println(res); 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-02-02 19:44:07 UTC (rev 4996) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-04 13:19:41 UTC (rev 4997) @@ -63,6 +63,19 @@ <rc>0</rc> </testSpec> <testSpec> + <title>if ... then ... fi multi-line</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne +if true +then echo HI +fi + </script> + <output>HI +</output> + <rc>0</rc> + </testSpec> + <testSpec> <title>if ... then ... else ... fi</title> <command>test</command> <runMode>AS_SCRIPT</runMode> @@ -76,6 +89,25 @@ <rc>0</rc> </testSpec> <testSpec> + <title>if ... then ... else ... fi multi-line</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne +if true ; +then echo HI ; +else echo HO; +fi +if false +then echo HI +else echo HO +fi + </script> + <output>HI +HO +</output> + <rc>0</rc> + </testSpec> + <testSpec> <title>if ... then ... elif ... else ... fi</title> <command>test</command> <runMode>AS_SCRIPT</runMode> @@ -91,6 +123,38 @@ <rc>0</rc> </testSpec> <testSpec> + <title>if ... then ... elif ... else ... fi multi-line</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne +if true ; +then echo HI ; +elif false ; +then echo HO ; +else +echo HUM; +fi +if false ; +then echo HI ; +elif true ; +then +echo HO ; +else echo HUM; +fi +if false +then echo HI +elif false +then echo HO +else echo HUM +fi + </script> + <output>HI +HO +HUM +</output> + <rc>0</rc> + </testSpec> + <testSpec> <title>while ... do ... done</title> <command>test</command> <runMode>AS_SCRIPT</runMode> @@ -113,6 +177,31 @@ <rc>0</rc> </testSpec> <testSpec> + <title>while ... do ... done multi-line</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne +A=5 +while expr $A != 0 ; +do echo A is $A ; +A=`expr $A - 1`; +done + </script> + <output>1 +A is 5 +1 +A is 4 +1 +A is 3 +1 +A is 2 +1 +A is 1 +0 +</output> + <rc>0</rc> + </testSpec> + <testSpec> <title>while ... do ... break ... done</title> <command>test</command> <runMode>AS_SCRIPT</runMode> @@ -136,6 +225,33 @@ <rc>0</rc> </testSpec> <testSpec> + <title>while ... do ... break ... done multi-line</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=5 + while expr $A != 0 + do + echo A is $A + if expr $A = 2 ; then break ; fi ; A=`expr $A - 1` + done + </script> + <output>1 +A is 5 +0 +1 +A is 4 +0 +1 +A is 3 +0 +1 +A is 2 +1 +</output> + <rc>0</rc> + </testSpec> + <testSpec> <title>${...} expansions</title> <command>test</command> <runMode>AS_SCRIPT</runMode> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-07 06:23:19
|
Revision: 5001 http://jnode.svn.sourceforge.net/jnode/?rev=5001&view=rev Author: crawley Date: 2009-02-07 06:23:16 +0000 (Sat, 07 Feb 2009) Log Message: ----------- Implemented ${...<op>...} where <op> is '#', '##', '%' or '%%'. Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 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/PathnamePattern.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 2009-02-07 06:21:18 UTC (rev 5000) +++ trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 2009-02-07 06:23:16 UTC (rev 5001) @@ -43,28 +43,36 @@ * character class "[abz]" matches one of "a", "b" or "z". Ranges are allowed, * so that "[0-9A-F]" matches a hexadecimal digit. If the first character of a * character class is "!" or "^", the character class is negated; i.e. - * "[^a-zA-Z]" matches any chatacter that is not an ASCII letter. + * "[^a-zA-Z]" matches any character that is not an ASCII letter. * <li>A single quote ("'") causes characters up to the next "'" to be treated * as literal characters. * <li>A backslash ("\") causes the next character (even a single quote) to be * treated as a literal character; i.e. any special meaning. * </ul> - * + * <p> * Patterns are first split into file components on "/" boundaries, then the * sub-patterns are used to match names in a given directory. Neither quoting or * escaping affect "/" interpretation, and a "/" in a character class causes it * to be treated as literal characters. - * + * <p> * The pattern expander treats "dot" files (i.e. files starting with ".") as * hidden. A hidden file is only matched when the pattern has an explicit "." as * the first character of a component. Thus the pattern "*" does not match "." * or "..", but the pattern ".*" does. - * + * <p> + * This class also exposes a static method for compiling patterns in the UNIX + * shell-style syntax to Java {@link Pattern} objects. The resulting + * objects allow you to use the shell-style syntax for matching arbitrary + * strings. The pathname-specific matching behaviors of PathnamePattern + * such as implicit anchoring, and the handling of '/' in character classes + * are supported via flags. + * <p> * TODO: * <ul> * <li>Provide a method that returns a "lazy" pathname iterator for cases where * we don't want to build a (potentially huge) in-memory list of pathnames. - * <li>Support expansions of ~ and {..,..} patterns. + * <li>Support expansions of ~ and {..,..} patterns. (Note that the latter are + * not part of the POSIX specification.) * <li>Add a parameter (or parameters) to allow the caller to limit the size of * the result list. * </ul> @@ -100,7 +108,7 @@ * character. For example, the sequence "\*" in a pattern will match a "*" * character in a filename. */ - public static final int SLASH_ESCAPES = 0x08; + public static final int BACKSLASH_ESCAPES = 0x08; /** * When set, this flag causes characters inside matching single-quote @@ -115,9 +123,36 @@ * recognized. */ public static final int CHARACTER_CLASSES = 0x20; + + /** + * When set, the pattern is anchored to the left of the string to be searched. + * This is set implicitly by the pathname matching methods. + */ + public static final int ANCHOR_LEFT = 0x40; + + /** + * When set, the pattern is anchored to the right of the string to be searched. + * This is set implicitly by the pathname matching methods. + */ + public static final int ANCHOR_RIGHT = 0x80; + + /** + * When set, '*' is eager, matching as many characters as possible. + * This is set implicitly by the pathname matching methods. + * matching is always eager. + */ + public static final int EAGER = 0x100; + + /** + * When set, an unescaped '/' inside a character class causes the entire class + * to be interpreted as a literal character sequence. + * This is set implicitly by the pathname matching methods. + */ + public static final int SLASH_DISABLES_CHARACTER_CLASSES = 0x200; + public static final int DEFAULT_FLAGS = SORT_MATCHES | HIDE_DOT_FILENAMES - | INCLUDE_DOT_AND_DOTDOT | SLASH_ESCAPES | SINGLE_QUOTE_ESCAPES + | INCLUDE_DOT_AND_DOTDOT | BACKSLASH_ESCAPES | SINGLE_QUOTE_ESCAPES | CHARACTER_CLASSES; private static final boolean DEBUG = false; @@ -127,7 +162,7 @@ private final boolean isAbsolute; // Use a weak reference for the pattern cache to avoid storage leakage. - private static WeakReference<HashMap<String, PathnamePattern>> compiledPatterns; + private static WeakReference<HashMap<String, PathnamePattern>> cache; private PathnamePattern(String source, Object[] pattern, boolean isAbsolute) { this.source = source; @@ -189,8 +224,7 @@ } }; // A directory's "." and ".." entries are not returned by - // File.listFiles - // so we have to match / add them explicitly. + // File.listFiles so we have to match / add them explicitly. if ((flags & INCLUDE_DOT_AND_DOTDOT) != 0) { if (filter.accept(current, ".")) { matches.add(new File(current, ".")); @@ -228,8 +262,8 @@ * @param source the pattern source * @return a compiler pattern for the source. */ - public static PathnamePattern compile(String source) { - return compile(source, DEFAULT_FLAGS); + public static PathnamePattern compilePathPattern(String source) { + return compilePathPattern(source, DEFAULT_FLAGS); } /** @@ -242,12 +276,11 @@ * @param flags pattern compilation flags * @return a compiler pattern for the source. */ - public static PathnamePattern compile(String source, int flags) { + public static PathnamePattern compilePathPattern(String source, int flags) { String key = flags + ":" + source; synchronized (PathnamePattern.class) { HashMap<String, PathnamePattern> cp; - if (compiledPatterns != null - && (cp = compiledPatterns.get()) != null) { + if (cache != null && (cp = cache.get()) != null) { PathnamePattern pat = cp.get(key); if (pat != null) { return pat; @@ -268,19 +301,22 @@ Object[] res = new Object[parts.length]; for (int i = 0; i < parts.length; i++) { String part = parts[i]; - res[i] = (isPattern(part, flags)) ? Pattern.compile(createRegex( - part, flags)) : part; - if (DEBUG) + if (isPattern(part, flags)) { + res[i] = compilePosixShellPattern(part, + flags | ANCHOR_LEFT | ANCHOR_RIGHT | EAGER | SLASH_DISABLES_CHARACTER_CLASSES); + } else { + res[i] = part; + } + if (DEBUG) { System.err.println(i + ": " + res[i]); + } } PathnamePattern pat = new PathnamePattern(source, res, isAbsolute); synchronized (PathnamePattern.class) { HashMap<String, PathnamePattern> cp = null; - if (compiledPatterns == null - || (cp = compiledPatterns.get()) == null) { + if (cache == null || (cp = cache.get()) == null) { cp = new HashMap<String, PathnamePattern>(); - compiledPatterns = new WeakReference<HashMap<String, PathnamePattern>>( - cp); + cache = new WeakReference<HashMap<String, PathnamePattern>>(cp); } cp.put(key, pat); } @@ -320,7 +356,7 @@ } break; case '\\': - if ((flags & SLASH_ESCAPES) != 0) { + if ((flags & BACKSLASH_ESCAPES) != 0) { return true; } break; @@ -336,20 +372,25 @@ } /** - * Turn a string representing a pathname component into a regex. + * Turn a string in POSIX shell pattern syntax into a regex. This method + * generates a {@link Pattern} that can be matched against a character sequence. * - * @param filePattern the pathname pattern component - * @return the corresponding regex. + * @param pattern the pattern in shell syntax. + * @return the corresponding regex as a {@link Pattern}. */ - private static String createRegex(String filePattern, int flags) { + public static Pattern compilePosixShellPattern(String pattern, int flags) { // This method needs to be really careful to avoid 'ordinary' characters // in the source pattern being accidentally mapped to Java regex // meta-characters. - int len = filePattern.length(); + int len = pattern.length(); StringBuffer sb = new StringBuffer(len); boolean quoted = false; + boolean eager = (flags & EAGER) != 0; + if ((flags & ANCHOR_LEFT) != 0) { + sb.append('^'); + } for (int i = 0; i < len; i++) { - char ch = filePattern.charAt(i); + char ch = pattern.charAt(i); switch (ch) { case '?': if (quoted) { @@ -364,23 +405,24 @@ if (quoted) { sb.append(ch); } else if (i == 0 && (flags & HIDE_DOT_FILENAMES) != 0) { - sb.append("(|[^\\.].*)"); + sb.append("(|[^\\.]").append(eager ? ".*" : ".*?").append(")"); } else { - sb.append(".*"); + sb.append(eager ? ".*" : ".*?"); } break; case '[': if ((flags & CHARACTER_CLASSES) != 0) { int j; StringBuffer sb2 = new StringBuffer(len); + boolean charClassOK = true; LOOP: for (j = i + 1; j < len; j++) { - char ch2 = filePattern.charAt(j); + char ch2 = pattern.charAt(j); switch (ch2) { case ']': break LOOP; case '\\': - sb2.append(protect(filePattern.charAt(++j))); + sb2.append(protect(pattern.charAt(++j))); break; case '!': case '^': @@ -389,12 +431,19 @@ case '-': sb2.append('-'); break; + case '/': + sb2.append(protect(ch2)); + charClassOK = ((flags & SLASH_DISABLES_CHARACTER_CLASSES) == 0); + break; default: sb2.append(protect(ch2)); } } if (j == len) { - sb.append('['); + sb.append(protect('[')); + } else if (!charClassOK) { + sb.append(protect('[')).append(sb2).append(protect(']')); + i = j; } else { sb.append("[").append(sb2).append(']'); i = j; @@ -404,8 +453,8 @@ } break; case '\\': - if ((flags & SLASH_ESCAPES) != 0) { - sb.append(protect(filePattern.charAt(++i))); + if ((flags & BACKSLASH_ESCAPES) != 0) { + sb.append(protect(pattern.charAt(++i))); } else { sb.append(protect(ch)); } @@ -414,7 +463,6 @@ if ((flags & SINGLE_QUOTE_ESCAPES) != 0) { quoted = !quoted; } else { - sb.append(protect(ch)); } break; @@ -422,7 +470,10 @@ sb.append(protect(ch)); } } - return sb.toString(); + if ((flags & ANCHOR_RIGHT) != 0) { + sb.append('$'); + } + return Pattern.compile(sb.toString()); } private static String protect(char ch) { Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-07 06:21:18 UTC (rev 5000) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-07 06:23:16 UTC (rev 5001) @@ -43,7 +43,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.tools.ant.types.Path; import org.jnode.shell.Command; import org.jnode.shell.CommandLine; import org.jnode.shell.CommandThread; @@ -380,7 +383,7 @@ globbedWordTokens.add(wordToken); return; } - PathnamePattern pattern = PathnamePattern.compile(word); + PathnamePattern pattern = PathnamePattern.compilePathPattern(word); LinkedList<String> paths = pattern.expand(new File(".")); // If it doesn't match anything, a pattern 'expands' to itself. if (paths.isEmpty()) { @@ -775,11 +778,55 @@ } else { return value; } + case HASH: + return patternEdit(value, word, false, false); + case DHASH: + return patternEdit(value, word, false, true); + case PERCENT: + return patternEdit(value, word, true, false); + case DPERCENT: + return patternEdit(value, word, true, true); default: throw new ShellFailureException("not implemented"); } } + private String patternEdit(String value, String pattern, boolean suffix, boolean eager) { + if (value == null || value.length() == 0) { + return ""; + } + if (pattern == null || pattern.length() == 0) { + return value; + } + // FIXME ... this does not work for a suffix == true, eager == false. We + // translate '*' to '.*?', but that won't give us the shortest suffix because + // Patterns inherently match from left to right. + int flags = (suffix ? PathnamePattern.ANCHOR_RIGHT : PathnamePattern.ANCHOR_LEFT) | + (eager ? PathnamePattern.EAGER : 0); + Pattern p = PathnamePattern.compilePosixShellPattern(pattern, + PathnamePattern.DEFAULT_FLAGS | flags); + Matcher m = p.matcher(value); + if (m.find()) { + if (suffix) { + return value.substring(0, m.start()); + } else { + return value.substring(m.end()); + } + } else { + return value; + } + } + + @SuppressWarnings("unused") + private String reverse(String str) { + StringBuilder sb = new StringBuilder(str.length()); + for (int i = str.length() - 1; i >= 0; i--) { + sb.append(str.charAt(i)); + } + return sb.toString(); + } + + private String variable(String parameter) throws ShellSyntaxException { if (parameter.length() == 1) { String tmp = specialVariable(parameter.charAt(0)); 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-02-07 06:21:18 UTC (rev 5000) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-07 06:23:16 UTC (rev 5001) @@ -517,4 +517,73 @@ </output> <rc>0</rc> </testSpec> + <testSpec> + <title>${..#..} expansions</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B=caaat + echo A hash ca is ${A#ca} + echo B hash ca is ${B#ca} + echo A hash c\? is ${A#c?} + echo B hash c\? is ${B#c?} + echo A hash c\* is ${A#c*} + echo B hash c\* is ${B#c*} + </script> + <output>A hash ca is t +B hash ca is aat +A hash c? is t +B hash c? is aat +A hash c* is at +B hash c* is aaat +</output> + <rc>0</rc> + </testSpec> + <testSpec> + <title>${..##..} expansions</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B=caaat + echo A hashhash ca is ${A##ca} + echo B hashhash ca is ${B##ca} + echo A hashhash c\? is ${A##c?} + echo B hashhash c\? is ${B##c?} + echo A hashhash c\* is ${A##c*} + echo B hashhash c\* is ${B##c*} + </script> + <output>A hashhash ca is t +B hashhash ca is aat +A hashhash c? is t +B hashhash c? is aat +A hashhash c* is +B hashhash c* is +</output> + <rc>0</rc> + </testSpec> + <testSpec> + <title>${..%..} expansions</title> + <command>test</command> + <runMode>AS_SCRIPT</runMode> + <script>#!bjorne + A=cat + B=caaat + echo A % at is ${A%at} + echo B % at is ${B%at} + echo A % \?t is ${A%?t} + echo B % \?t is ${B%?t} + echo A % \*t is ${A%*t} + echo B % \*t is ${B%*t} + </script> + <output>A % at is c +B % at is caa +A % ?t is c +B % ?t is caa +A % *t is ca +B % *t is caaa +</output> + <rc>0</rc> + </testSpec> </testSpecs> \ 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-02-08 04:04:09
|
Revision: 5003 http://jnode.svn.sourceforge.net/jnode/?rev=5003&view=rev Author: crawley Date: 2009-02-08 04:04:06 +0000 (Sun, 08 Feb 2009) Log Message: ----------- Implemented script arguments (via RunCommand, etc) and a first cut for $* and $@. 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/Shell.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/command/RunCommand.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java Modified: trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-02-07 09:59:22 UTC (rev 5002) +++ trunk/shell/src/shell/org/jnode/shell/CommandInterpreter.java 2009-02-08 04:04:06 UTC (rev 5003) @@ -56,10 +56,13 @@ * @param shell the CommandShell that provides low-level command invocation, * command history and so on. * @param file the file to be interpreted + * @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 + * is {@code null}, no arguments are passed. * @return the return code. * @throws ShellException */ - int interpret(CommandShell shell, File file) throws ShellException; + int interpret(CommandShell shell, File file, String alias, String[] args) throws ShellException; /** * Parse and execute a command file, returning the resulting return code. @@ -67,10 +70,13 @@ * @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 + * is {@code null}, no arguments are passed. * @return the return code. * @throws ShellException */ - int interpret(CommandShell shell, Reader reader) throws ShellException; + int interpret(CommandShell shell, Reader reader, String alias, String[] args) throws ShellException; /** * Parse a partial command line, returning the command line fragment to be Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-02-07 09:59:22 UTC (rev 5002) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-02-08 04:04:06 UTC (rev 5003) @@ -296,9 +296,9 @@ final File jnode_ini = new File(java_home + '/' + name); try { if (jnode_ini.exists()) { - runCommandFile(jnode_ini); + runCommandFile(jnode_ini, null, null); } else if (getClass().getResource(name) != null) { - runCommandResource(name); + runCommandResource(name, null); } } catch (ShellException ex) { errPW.println("Error while processing " + jnode_ini + ": " + ex.getMessage()); @@ -316,9 +316,9 @@ final File shell_ini = new File(user_home + '/' + name); try { if (shell_ini.exists()) { - runCommandFile(shell_ini); + runCommandFile(shell_ini, null, null); } else if (getClass().getResource(name) != null) { - runCommandResource(name); + runCommandResource(name, null); } } catch (ShellException ex) { errPW.println("Error while processing " + shell_ini + ": " + ex.getMessage()); @@ -847,12 +847,15 @@ return ShellUtils.createInvoker("default", this); } - public int runCommandFile(File file) throws ShellException { + public int runCommandFile(File file, String alias, String[] args) throws ShellException { // FIXME extend to allow arguments to be passed to the script. boolean enabled = setHistoryEnabled(false); try { CommandInterpreter interpreter = createInterpreter(new FileReader(file)); - return interpreter.interpret(this, file); + if (alias == null) { + alias = file.getAbsolutePath(); + } + return interpreter.interpret(this, file, alias, args); } catch (IOException ex) { throw new ShellException("Cannot open command file: " + ex.getMessage(), ex); } finally { @@ -860,7 +863,7 @@ } } - public int runCommandResource(String resource) throws ShellException { + public int runCommandResource(String resource, String[] args) throws ShellException { boolean enabled = setHistoryEnabled(false); try { int result; @@ -871,7 +874,7 @@ } else { CommandInterpreter interpreter = createInterpreter(new InputStreamReader(input)); Reader reader = new InputStreamReader(getClass().getResourceAsStream(resource)); - result = interpreter.interpret(this, reader); + result = interpreter.interpret(this, reader, resource, args); } return result; } finally { Modified: trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-02-07 09:59:22 UTC (rev 5002) +++ trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-02-08 04:04:06 UTC (rev 5003) @@ -107,12 +107,22 @@ throw new ShellException("Command arguments don't match syntax", ex); } } - + + /** + * {@inheritDoc} + * + * The default interpreter and its subtypes treat 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. + */ @Override - public int interpret(CommandShell shell, Reader reader) throws ShellException { - // The default interpreter and subtypes process the command file one line at a time, - // ignoring any line whose first non-whitespace character is '#'. There is no notion - // of multi-line commands. + public int interpret(CommandShell shell, Reader reader, String alias, String[] args) + throws ShellException { + if (args != null && args.length > 0) { + throw new ShellException( + "The " + getName() + " interpreter does not support script file arguments"); + } try { BufferedReader br = new BufferedReader(reader); String line; @@ -143,10 +153,19 @@ return false; } + /** + * {@inheritDoc} + * + * The default interpreter and its subtypes treat 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. + */ @Override - public int interpret(CommandShell shell, File file) throws ShellException { + public int interpret(CommandShell shell, File file, String alias, String[] args) + throws ShellException { try { - return interpret(shell, new FileReader(file)); + return interpret(shell, new FileReader(file), alias, args); } catch (FileNotFoundException ex) { throw new ShellException("Problem reading command file: " + ex.getMessage(), ex); } Modified: trunk/shell/src/shell/org/jnode/shell/Shell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/Shell.java 2009-02-07 09:59:22 UTC (rev 5002) +++ trunk/shell/src/shell/org/jnode/shell/Shell.java 2009-02-08 04:04:06 UTC (rev 5003) @@ -70,9 +70,13 @@ * the shell gets to decide which interpreter to use. * * @param file the command file + * @param alias the command alias used to launch the script. If this parameter is + * {@code null}, the command file name will be used. + * @param args command line arguments to be passed to the script. If this parameter + * is {@code null}, no arguments are passed. * @throws ShellException */ - public int runCommandFile(File file) throws ShellException; + public int runCommandFile(File file, String alias, String[] args) throws ShellException; /** * Resolve a command name to a CommandInfo object. Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-07 09:59:22 UTC (rev 5002) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-08 04:04:06 UTC (rev 5003) @@ -39,6 +39,7 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -239,6 +240,14 @@ return copyStreamHolders(holders); } + void setArgs(String[] args) { + this.args = Arrays.asList(args.clone()); + } + + void setCommand(String command) { + this.command = command; + } + /** * This method implements 'NAME=VALUE'. If variable NAME does not exist, it * is created as an unexported shell variable. @@ -262,7 +271,7 @@ * @param name the name of the variable to be tested * @return <code>true</code> if the variable is set. */ - public boolean isVariableSet(String name) { + boolean isVariableSet(String name) { return variables.get(name) != null; } @@ -271,7 +280,7 @@ * * @param name the name of the variable to be unset */ - public void unsetVariableValue(String name) { + void unsetVariableValue(String name) { variables.remove(name); } @@ -280,7 +289,7 @@ * * @param name the name of the variable to be exported / unexported */ - public void setExported(String name, boolean exported) { + void setExported(String name, boolean exported) { VariableSlot var = variables.get(name); if (var == null) { if (exported) { @@ -854,8 +863,9 @@ case '#': return Integer.toString(args.size()); case '@': + return concatenateArgs(false); case '*': - throw new ShellFailureException("not implemented"); + return concatenateArgs(false); case '?': return Integer.toString(lastReturnCode); case '!': @@ -872,17 +882,30 @@ case '7': case '8': case '9': - return argVariable(ch - '0'); + return argVariable(ch); default: return null; } } - private String argVariable(int argNo) { + private String concatenateArgs(boolean isStar) { + // FIXME - implement $@ versus $* differences; i.e. quoting and $IFS behavior. + StringBuilder sb = new StringBuilder(); + for (String arg : args) { + if (sb.length() > 0) { + sb.append(' '); + } + sb.append(arg); + } + return sb.toString(); + } + + private String argVariable(int argChar) { + int argNo = argChar - '0'; if (argNo == 0) { return command; } else if (argNo <= args.size()) { - return args.get(argNo); + return args.get(argNo - 1); } else { return ""; } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-07 09:59:22 UTC (rev 5002) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-08 04:04:06 UTC (rev 5003) @@ -250,8 +250,10 @@ } @Override - public int interpret(CommandShell shell, Reader reader) throws ShellException { - // FIXME ... update this to support multi-line commands. + public int interpret(CommandShell shell, Reader reader, String alias, String[] args) + throws ShellException { + context.setCommand(alias == null ? "" : alias); + context.setArgs(args == null ? new String[0] : args); try { BufferedReader br = new BufferedReader(reader); String line; @@ -301,9 +303,9 @@ } @Override - public int interpret(CommandShell shell, File file) throws ShellException { + public int interpret(CommandShell shell, File file, String alias, String[] args) throws ShellException { try { - return interpret(shell, new FileReader(file)); + return interpret(shell, new FileReader(file), alias, args); } catch (FileNotFoundException ex) { throw new ShellException("Problem reading command file: " + ex.getMessage(), ex); } Modified: trunk/shell/src/shell/org/jnode/shell/command/RunCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/RunCommand.java 2009-02-07 09:59:22 UTC (rev 5002) +++ trunk/shell/src/shell/org/jnode/shell/command/RunCommand.java 2009-02-08 04:04:06 UTC (rev 5003) @@ -30,6 +30,7 @@ import org.jnode.shell.ShellUtils; import org.jnode.shell.syntax.Argument; import org.jnode.shell.syntax.FileArgument; +import org.jnode.shell.syntax.StringArgument; /** * Load and execute a command file. @@ -39,11 +40,14 @@ */ public class RunCommand extends AbstractCommand { - private final FileArgument ARG_FILE = new FileArgument("file", Argument.MANDATORY, "The command file name"); + private final FileArgument ARG_FILE = + new FileArgument("file", Argument.MANDATORY, "The command script file name"); + private final StringArgument ARG_ARGS = + new StringArgument("args", Argument.OPTIONAL | Argument.MULTIPLE, "Arguments passed to the script"); public RunCommand() { super("Run a command file"); - registerArguments(ARG_FILE); + registerArguments(ARG_FILE, ARG_ARGS); } public static void main(String[] args) throws Exception { @@ -67,8 +71,10 @@ err.println("Shell is null."); exit(2); } + + String[] args = ARG_ARGS.getValues(); - int rc = shell.runCommandFile(file); + int rc = shell.runCommandFile(file, null, args); if (rc != 0) { exit(rc); } 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-02-07 09:59:22 UTC (rev 5002) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-08 04:04:06 UTC (rev 5003) @@ -472,4 +472,23 @@ B % *t is caaa </output> </testSpec> + <testSpec title="script arguments" command="test" runMode="AS_SCRIPT" rc="0"> + <script>#!bjorne + echo $0 + echo $1 + echo $2 + echo $3 + echo $# + echo $* + </script> + <arg>arg1</arg> + <arg>arg2</arg> + <output>test +arg1 +arg2 + +2 +arg1 arg2 +</output> + </testSpec> </testSet> \ No newline at end of file Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-02-07 09:59:22 UTC (rev 5002) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-02-08 04:04:06 UTC (rev 5003) @@ -41,8 +41,6 @@ @Override public int run() throws Exception { -// String[] args = spec.getArgs().toArray(new String[0]); -// CommandLine cmdLine = new CommandLine(spec.getCommand(), args); tempScriptFile = new File(System.getProperty("java.io.tmpdir"), spec.getCommand()); Writer w = null; try { @@ -52,7 +50,8 @@ } finally { w.close(); } - int rc = getShell().runCommandFile(tempScriptFile); + int rc = getShell().runCommandFile(tempScriptFile, + spec.getCommand(), spec.getArgs().toArray(new String[0])); return check(rc) ? 0 : 1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-08 06:42:38
|
Revision: 5005 http://jnode.svn.sourceforge.net/jnode/?rev=5005&view=rev Author: crawley Date: 2009-02-08 06:42:27 +0000 (Sun, 08 Feb 2009) Log Message: ----------- Echoed commands (set -x) should show command arguments quoted if they contain spaces, etc. 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-02-08 04:17:52 UTC (rev 5004) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-08 06:42:27 UTC (rev 5005) @@ -404,10 +404,10 @@ /** * Split a character sequence into word tokens, dealing with and removing any - * non-literal + * non-literal quotes. * * @param text the characters to be split - * @return the destination for the tokens. + * @return the resulting list of tokens. * @throws ShellException */ public List<BjorneToken> split(CharSequence text) throws ShellException { @@ -922,7 +922,7 @@ StringBuilder sb = new StringBuilder(); sb.append(" + ").append(command.getCommandName()); for (String arg : command.getArguments()) { - sb.append(" ").append(arg); + sb.append(" ").append(interpreter.escapeWord(arg)); } resolvePrintStream(streams[Command.STD_ERR]).println(sb); } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-08 04:17:52 UTC (rev 5004) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-08 06:42:27 UTC (rev 5005) @@ -212,8 +212,12 @@ @Override public String escapeWord(String word) { - // TODO implement this properly - return word; + // FIXME ... do this properly + if (word.indexOf(' ') == -1 && word.indexOf('\t') == -1) { + return word; + } else { + return "'" + word + "'"; + } } int interpret(CommandShell shell, String command, StringWriter capture, boolean source) 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-02-08 04:17:52 UTC (rev 5004) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-08 06:42:27 UTC (rev 5005) @@ -491,4 +491,22 @@ arg1 arg2 </output> </testSpec> + <testSpec title="set -x" command="test" runMode="AS_SCRIPT" rc="0"> + <script>#!bjorne + set -x + echo a b + echo 'a b' + echo "a b" + </script> + <arg>arg1</arg> + <arg>arg2</arg> + <output>a b +a b +a b +</output> + <error> + echo a b + + echo 'a b' + + echo 'a b' +</error> + </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-02-08 08:01:53
|
Revision: 5006 http://jnode.svn.sourceforge.net/jnode/?rev=5006&view=rev Author: crawley Date: 2009-02-08 08:01:48 +0000 (Sun, 08 Feb 2009) Log Message: ----------- Fix quote handling of "$X" and related stuff. Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java Added Paths: ----------- trunk/shell/src/shell/org/jnode/shell/bjorne/CharIterator.java trunk/shell/src/shell/org/jnode/shell/bjorne/StreamHolder.java trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-08 06:42:27 UTC (rev 5005) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-08 08:01:48 UTC (rev 5006) @@ -541,7 +541,8 @@ if (quote == '\'') { sb.append('$'); } else { - sb.append(dollarExpansion(ci, quote)); + String tmp = dollarExpansion(ci, quote); + sb.append(tmp == null ? "" : tmp); } break; @@ -573,27 +574,16 @@ case '?': case '!': case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return specialVariable(ch); + return specialVariable(ch, quote == '"'); default: StringBuffer sb = new StringBuffer().append((char) ch); ch = ci.peekCh(); - while ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= 'a' && ch <= 'z') || ch == '_') { + while ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_') { sb.append((char) ch); ci.nextCh(); ch = ci.peekCh(); } - VariableSlot var = variables.get(sb.toString()); - return (var != null) ? var.value : ""; + return variable(sb.toString()); } } @@ -741,7 +731,7 @@ // Extract the word word = sb.substring(i); } - String value = variable(parameter); + String value = dollarExpansion(new CharIterator(parameter), '\000'); switch (operator) { case NONE: return (value != null) ? value : ""; @@ -835,12 +825,6 @@ private String variable(String parameter) throws ShellSyntaxException { - if (parameter.length() == 1) { - String tmp = specialVariable(parameter.charAt(0)); - if (tmp != null) { - return tmp; - } - } if (BjorneToken.isName(parameter)) { VariableSlot var = variables.get(parameter); return (var != null) ? var.value : null; @@ -854,58 +838,49 @@ } } - private String specialVariable(int ch) { + private String specialVariable(int ch, boolean inDoubleQuotes) { switch (ch) { case '$': return Integer.toString(shellPid); case '#': return Integer.toString(args.size()); case '@': - return concatenateArgs(false); + return concatenateArgs(false, inDoubleQuotes); case '*': - return concatenateArgs(false); + return concatenateArgs(true, inDoubleQuotes); case '?': return Integer.toString(lastReturnCode); case '!': return Integer.toString(lastAsyncPid); case '-': return options; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return argVariable(ch); default: return null; } } - private String concatenateArgs(boolean isStar) { - // FIXME - implement $@ versus $* differences; i.e. quoting and $IFS behavior. + private String concatenateArgs(boolean isStar, boolean inDoubleQuotes) { StringBuilder sb = new StringBuilder(); for (String arg : args) { if (sb.length() > 0) { - sb.append(' '); + if (isStar || !inDoubleQuotes) { + sb.append(' '); + } else { + sb.append("\" \""); + } } sb.append(arg); } return sb.toString(); } - private String argVariable(int argChar) { - int argNo = argChar - '0'; + private String argVariable(int argNo) { if (argNo == 0) { return command; } else if (argNo <= args.size()) { return args.get(argNo - 1); } else { - return ""; + return null; } } @@ -1115,92 +1090,4 @@ // TODO Auto-generated method stub return false; } - - private static class VariableSlot { - public String value; - - public boolean exported; - - public VariableSlot(String value, boolean exported) { - if (value == null) { - throw new ShellFailureException("null value"); - } - this.value = value; - this.exported = exported; - } - - public VariableSlot(VariableSlot other) { - this.value = other.value; - this.exported = other.exported; - } - } - - public static class StreamHolder { - private CommandIO stream; - private boolean isMine; - - public StreamHolder(CommandIO stream, boolean isMine) { - this.stream = stream; - this.isMine = isMine; - } - - public StreamHolder(StreamHolder other) { - this.stream = other.stream; - this.isMine = false; - } - - public CommandIO getStream() { - return stream; - } - - public void setStream(CommandIO stream, boolean isMine) { - close(); - this.stream = stream; - this.isMine = isMine; - } - - public void close() { - if (isMine) { - try { - isMine = false; // just in case we call close twice - stream.close(); - } catch (IOException ex) { - // FIXME - should we squash or report this? - } - } - } - - public boolean isMine() { - return isMine; - } - } - - private static class CharIterator { - private CharSequence str; - private int pos, start, limit; - - public CharIterator(CharSequence str) { - this.str = str; - this.start = pos = 0; - this.limit = str.length(); - } - - public CharIterator(CharSequence str, int start, int limit) { - this.str = str; - this.start = pos = start; - this.limit = limit; - } - - public int nextCh() { - return (pos >= limit) ? -1 : str.charAt(pos++); - } - - public int peekCh() { - return (pos >= limit) ? -1 : str.charAt(pos); - } - - public int lastCh() { - return (pos > start) ? str.charAt(pos - 1) : -1; - } - } } Added: trunk/shell/src/shell/org/jnode/shell/bjorne/CharIterator.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/CharIterator.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/CharIterator.java 2009-02-08 08:01:48 UTC (rev 5006) @@ -0,0 +1,50 @@ +/* + * $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; + +class CharIterator { + private CharSequence str; + private int pos, start, limit; + + public CharIterator(CharSequence str) { + this.str = str; + this.start = pos = 0; + this.limit = str.length(); + } + + public CharIterator(CharSequence str, int start, int limit) { + this.str = str; + this.start = pos = start; + this.limit = limit; + } + + public int nextCh() { + return (pos >= limit) ? -1 : str.charAt(pos++); + } + + public int peekCh() { + return (pos >= limit) ? -1 : str.charAt(pos); + } + + public int lastCh() { + return (pos > start) ? str.charAt(pos - 1) : -1; + } +} \ No newline at end of file Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java 2009-02-08 06:42:27 UTC (rev 5005) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java 2009-02-08 08:01:48 UTC (rev 5006) @@ -33,7 +33,6 @@ import org.jnode.shell.ShellException; import org.jnode.shell.ShellFailureException; import org.jnode.shell.ThreadExitListener; -import org.jnode.shell.bjorne.BjorneContext.StreamHolder; import org.jnode.shell.help.CompletionException; import org.jnode.shell.io.CommandIO; import org.jnode.shell.io.CommandInput; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-02-08 06:42:27 UTC (rev 5005) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-02-08 08:01:48 UTC (rev 5006) @@ -68,7 +68,7 @@ @Override public int execute(final BjorneContext context) throws ShellException { - BjorneContext.StreamHolder[] holders = null; + StreamHolder[] holders = null; int rc; try { BjorneToken[] words = getWords(); @@ -98,7 +98,7 @@ } } finally { if (holders != null) { - for (BjorneContext.StreamHolder holder : holders) { + for (StreamHolder holder : holders) { holder.close(); } } Added: trunk/shell/src/shell/org/jnode/shell/bjorne/StreamHolder.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/StreamHolder.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/StreamHolder.java 2009-02-08 08:01:48 UTC (rev 5006) @@ -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 java.io.IOException; + +import org.jnode.shell.io.CommandIO; + +public class StreamHolder { + CommandIO stream; + private boolean isMine; + + public StreamHolder(CommandIO stream, boolean isMine) { + this.stream = stream; + this.isMine = isMine; + } + + public StreamHolder(StreamHolder other) { + this.stream = other.stream; + this.isMine = false; + } + + public CommandIO getStream() { + return stream; + } + + public void setStream(CommandIO stream, boolean isMine) { + close(); + this.stream = stream; + this.isMine = isMine; + } + + public void close() { + if (isMine) { + try { + isMine = false; // just in case we call close twice + stream.close(); + } catch (IOException ex) { + // FIXME - should we squash or report this? + } + } + } + + public boolean isMine() { + return isMine; + } +} \ No newline at end of file Added: trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java 2009-02-08 08:01:48 UTC (rev 5006) @@ -0,0 +1,41 @@ +/* + * $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.ShellFailureException; + +class VariableSlot { + public String value; + + public boolean exported; + + public VariableSlot(String value, boolean exported) { + if (value == null) { + throw new ShellFailureException("null value"); + } + this.value = value; + this.exported = exported; + } + + public VariableSlot(VariableSlot other) { + this.value = other.value; + this.exported = other.exported; + } +} \ No newline at end of file Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java 2009-02-08 06:42:27 UTC (rev 5005) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneContextTests.java 2009-02-08 08:01:48 UTC (rev 5006) @@ -31,6 +31,7 @@ import org.jnode.shell.ShellException; import org.jnode.shell.bjorne.BjorneContext; import org.jnode.shell.bjorne.BjorneToken; +import org.jnode.shell.bjorne.StreamHolder; public class BjorneContextTests extends TestCase { @@ -121,7 +122,7 @@ } public void testExpand14() throws ShellException { - BjorneContext parentContext = new BjorneContext(null, new BjorneContext.StreamHolder[0]); + BjorneContext parentContext = new BjorneContext(null, new StreamHolder[0]); parentContext.setVariable("A", "A"); BjorneContext context = new BjorneContext(parentContext); List<BjorneToken> expansion = context.expandAndSplit("'$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-02-08 06:42:27 UTC (rev 5005) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-08 08:01:48 UTC (rev 5006) @@ -491,22 +491,34 @@ arg1 arg2 </output> </testSpec> - <testSpec title="set -x" command="test" runMode="AS_SCRIPT" rc="0"> + <testSpec title="quote handling" command="test" runMode="AS_SCRIPT" rc="0"> <script>#!bjorne set -x echo a b echo 'a b' echo "a b" + echo $* + echo $@ + echo "$*" + echo "$@" </script> <arg>arg1</arg> <arg>arg2</arg> <output>a b a b a b +arg1 arg2 +arg1 arg2 +arg1 arg2 +arg1 arg2 </output> <error> + echo a b + echo 'a b' + echo 'a b' + + echo arg1 arg2 + + echo arg1 arg2 + + echo 'arg1 arg2' + + echo arg1 arg2 </error> </testSpec> </testSet> \ No newline at end of file Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-02-08 06:42:27 UTC (rev 5005) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-02-08 08:01:48 UTC (rev 5006) @@ -124,7 +124,6 @@ } - public TestSetSpecification loadTestSetSpecification(String specName, String base) throws Exception { TestSpecificationParser parser = new TestSpecificationParser(); InputStream is = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-08 13:20:44
|
Revision: 5007 http://jnode.svn.sourceforge.net/jnode/?rev=5007&view=rev Author: crawley Date: 2009-02-08 13:20:40 +0000 (Sun, 08 Feb 2009) Log Message: ----------- Improvements to 'set' built-in. Now understands options -x, +x, -f, +f, -- and setting of arguments. Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/bjorne/SetBuiltin.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/SetBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/SetBuiltin.java 2009-02-08 08:01:48 UTC (rev 5006) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/SetBuiltin.java 2009-02-08 13:20:40 UTC (rev 5007) @@ -20,23 +20,54 @@ package org.jnode.shell.bjorne; -import java.util.Iterator; +import java.util.ArrayList; +import java.util.List; import org.jnode.shell.CommandLine; import org.jnode.shell.ShellException; +import org.jnode.shell.ShellSyntaxException; final class SetBuiltin extends BjorneBuiltin { + @SuppressWarnings("deprecation") public int invoke(CommandLine command, BjorneInterpreter interpreter, BjorneContext context) throws ShellException { - Iterator<String> it = command.iterator(); - if (it.hasNext()) { - String flags = it.next(); - // FIXME ... lots more to implement ... - if (flags.equals("-x")) { - context.getParent().setEchoExpansions(true); + context = context.getParent(); + boolean optsDone = false; + boolean forceNewArgs = false; + List<String> newArgs = new ArrayList<String>(); + String[] args = command.getArguments(); + for (int i = 0; i < args.length; i++) { + String arg = args[i]; + if (optsDone) { + newArgs.add(arg); + } else if (arg.length() == 0 || + (arg.charAt(0) != '-' && arg.charAt(0) != '+')) { + optsDone = true; + newArgs.add(arg); + } else if (arg.equals("--")) { + optsDone = true; + forceNewArgs = true; + } else { + boolean set = arg.charAt(0) == '-'; + for (int j = 1; j < arg.length(); j++) { + switch (arg.charAt(j)) { + case 'x': + context.setEchoExpansions(set); + break; + case 'f': + context.setGlobbing(!set); + break; + default: + throw new ShellSyntaxException( + "Unknown set option: " + (set ? "-" : "+") + arg.charAt(j)); + } + } } } + if (forceNewArgs || newArgs.size() > 0) { + context.setArgs(newArgs.toArray(new String[newArgs.size()])); + } return 0; } } 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-02-08 08:01:48 UTC (rev 5006) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-08 13:20:40 UTC (rev 5007) @@ -491,6 +491,24 @@ arg1 arg2 </output> </testSpec> + <testSpec title="set arguments" command="test" runMode="AS_SCRIPT" rc="0"> + <script>#!bjorne + echo $* + set newarg1 newarg2 + echo $* + set -- newarg1 newarg2 + echo $* + set -- + echo $* + </script> + <arg>arg1</arg> + <arg>arg2</arg> + <output>arg1 arg2 +newarg1 newarg2 +newarg1 newarg2 + +</output> + </testSpec> <testSpec title="quote handling" command="test" runMode="AS_SCRIPT" rc="0"> <script>#!bjorne set -x This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-08 15:02:28
|
Revision: 5008 http://jnode.svn.sourceforge.net/jnode/?rev=5008&view=rev Author: crawley Date: 2009-02-08 15:02:25 +0000 (Sun, 08 Feb 2009) Log Message: ----------- Implemented 'shift' built-in 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 Added Paths: ----------- trunk/shell/src/shell/org/jnode/shell/bjorne/ShiftBuiltin.java Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-08 13:20:40 UTC (rev 5007) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-08 15:02:25 UTC (rev 5008) @@ -1090,4 +1090,12 @@ // TODO Auto-generated method stub return false; } + + public String[] getArgs() { + return args.toArray(new String[args.size()]); + } + + public int nosArgs() { + return args.size(); + } } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-08 13:20:40 UTC (rev 5007) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-08 15:02:25 UTC (rev 5008) @@ -142,6 +142,7 @@ BUILTINS.put("exit", new ExitBuiltin()); BUILTINS.put("return", new ReturnBuiltin()); BUILTINS.put("set", new SetBuiltin()); + BUILTINS.put("shift", new ShiftBuiltin()); BUILTINS.put(".", new SourceBuiltin()); BUILTINS.put(":", new ColonBuiltin()); } Added: trunk/shell/src/shell/org/jnode/shell/bjorne/ShiftBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ShiftBuiltin.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ShiftBuiltin.java 2009-02-08 15:02:25 UTC (rev 5008) @@ -0,0 +1,63 @@ +/* + * $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.CommandLine; +import org.jnode.shell.ShellException; +import org.jnode.shell.ShellSyntaxException; + +final class ShiftBuiltin extends BjorneBuiltin { + + @SuppressWarnings("deprecation") + public int invoke(CommandLine command, BjorneInterpreter interpreter, + BjorneContext context) throws ShellException { + context = context.getParent(); + String[] args = command.getArguments(); + int nos; + if (args.length == 0) { + nos = 1; + } else if (args.length == 1) { + try { + nos = Integer.parseInt(args[0]); + if (nos < 0) { + new ShellSyntaxException("Argument for 'shift' is negative: " + args[0]); + } + } catch (NumberFormatException ex) { + throw new ShellSyntaxException("Nonnumeric argument for 'shift': " + args[0]); + } + } else { + throw new ShellSyntaxException("Too many arguments for 'shift'"); + } + if (nos == 0) { + return 0; + } + int nosOldArgs = context.nosArgs(); + if (nos >= nosOldArgs) { + context.setArgs(new String[0]); + return nos == nosOldArgs ? 0 : 1; + } + String[] oldArgs = context.getArgs(); + String[] newArgs = new String[oldArgs.length - nos]; + System.arraycopy(oldArgs, nos, newArgs, 0, newArgs.length); + context.setArgs(newArgs); + return 0; + } +} 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-02-08 13:20:40 UTC (rev 5007) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-08 15:02:25 UTC (rev 5008) @@ -509,6 +509,27 @@ </output> </testSpec> + <testSpec title="set arguments" command="test" runMode="AS_SCRIPT" rc="0"> + <script>#!bjorne + echo $* + shift 0 + echo $* + shift + echo $* + shift 2 + echo $* + </script> + <arg>1</arg> + <arg>2</arg> + <arg>3</arg> + <arg>4</arg> + <arg>5</arg> + <output>1 2 3 4 5 +1 2 3 4 5 +2 3 4 5 +4 5 +</output> + </testSpec> <testSpec title="quote handling" command="test" runMode="AS_SCRIPT" rc="0"> <script>#!bjorne set -x This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-10 14:24:06
|
Revision: 5016 http://jnode.svn.sourceforge.net/jnode/?rev=5016&view=rev Author: crawley Date: 2009-02-10 14:23:53 +0000 (Tue, 10 Feb 2009) Log Message: ----------- Implement \<newline> continuations. Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-02-09 16:04:03 UTC (rev 5015) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-02-10 14:23:53 UTC (rev 5016) @@ -66,6 +66,7 @@ import static org.jnode.shell.bjorne.BjorneToken.TOK_WHILE; import static org.jnode.shell.bjorne.BjorneToken.TOK_WORD; +import org.jnode.shell.IncompleteCommandException; import org.jnode.shell.ShellFailureException; public class BjorneTokenizer { @@ -83,16 +84,79 @@ private final boolean debug; - public BjorneTokenizer(String text) { + /** + * 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 + */ + public BjorneTokenizer(String text) throws IncompleteCommandException { this(text, false); } - public BjorneTokenizer(String text, boolean debug) { - chars = text.toCharArray(); + /** + * 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 + */ + public BjorneTokenizer(String text, boolean debug) throws IncompleteCommandException { + chars = foldContinuations(text); len = chars.length; this.debug = debug; } + /** + * 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 + */ + private char[] foldContinuations(String text) throws IncompleteCommandException { + 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(); + } + + /** + * Get the next token without advancing. The default tokenization + * rules are used. + * + * @return the next token + */ public BjorneToken peek() { if (current == null) { current = advance(); @@ -103,6 +167,13 @@ return current; } + /** + * Get the next token without advancing, using the tokenization + * rules corresponding to the supplied 'context'. + * + * @param context gives the tokenization rules + * @return the next token + */ public BjorneToken peek(int context) { BjorneToken res = reinterpret(peek(), context); if (debug) { @@ -111,10 +182,20 @@ return res; } + /** + * Test if {@link #next()} will return something other that EOS. + * @return <code>true</code> if there are more tokens to be delivered. + */ public boolean hasNext() { return peek().getTokenType() != TOK_END_OF_STREAM; } + /** + * Get the next token and advance. The default tokenization + * rules are used. + * + * @return the next token + */ public BjorneToken next() { if (current == null) { prev = advance(); @@ -129,6 +210,10 @@ return prev; } + /** + * Backup one token in the token sequence. Calling this method twice without + * an intervening {@link #next()} call is invalid. + */ public void backup() { if (prev == null) { throw new ShellFailureException("incorrect backup"); @@ -142,6 +227,13 @@ prev = null; } + /** + * Get the next token and advance, using the tokenization + * rules corresponding to the supplied 'context'. + * + * @param context gives the tokenization rules + * @return the next token + */ public BjorneToken next(int context) { BjorneToken res = reinterpret(next(), context); if (debug) { @@ -150,6 +242,9 @@ return res; } + /** + * This operation is not supported. + */ public void remove() { throw new UnsupportedOperationException("remove not supported"); } Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java 2009-02-09 16:04:03 UTC (rev 5015) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java 2009-02-10 14:23:53 UTC (rev 5016) @@ -30,7 +30,7 @@ private static final boolean DEBUG = true; - public void testParser() { + public void testParser() throws ShellException { new BjorneParser(new BjorneTokenizer(""), null); } Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java 2009-02-09 16:04:03 UTC (rev 5015) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneTokenizerTests.java 2009-02-10 14:23:53 UTC (rev 5016) @@ -67,16 +67,26 @@ import static org.jnode.shell.bjorne.BjorneToken.TOK_WORD; import junit.framework.TestCase; +import org.jnode.shell.IncompleteCommandException; import org.jnode.shell.bjorne.BjorneToken; import org.jnode.shell.bjorne.BjorneTokenizer; public class BjorneTokenizerTests extends TestCase { - public void testBjorneTokenizer() { + public void testBjorneTokenizer() throws IncompleteCommandException { new BjorneTokenizer("hello"); } - public void testEmpty() { + public void testBjorneTokenizer2() { + try { + new BjorneTokenizer("hello\\"); + fail("no exception"); + } catch (IncompleteCommandException ex) { + // expected + } + } + + public void testEmpty() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer(""); BjorneToken token = tokenizer.peek(); assertEquals(TOK_END_OF_STREAM, token.getTokenType()); @@ -88,7 +98,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testNewline() { + public void testNewline() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer("\n"); BjorneToken token = tokenizer.next(); assertEquals(TOK_END_OF_LINE, token.getTokenType()); @@ -96,7 +106,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testBlanksAndNewlines() { + public void testBlanksAndNewlines() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer(" \n\t\n "); BjorneToken token = tokenizer.next(); assertEquals(TOK_END_OF_LINE, token.getTokenType()); @@ -106,7 +116,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testComments() { + public void testComments() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer( "# comment\n #comment 2\n # comment # 3"); BjorneToken token = tokenizer.next(); @@ -117,7 +127,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testSymbols() { + public void testSymbols() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer("; | & < > ( )"); BjorneToken token = tokenizer.next(); assertEquals(TOK_SEMI, token.getTokenType()); @@ -137,7 +147,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testSymbols2() { + public void testSymbols2() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer( "; ;; | || & && < << > >>"); BjorneToken token = tokenizer.next(); @@ -164,7 +174,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testSymbols3() { + public void testSymbols3() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer(";;;|||&&&<<<>>>"); BjorneToken token = tokenizer.next(); assertEquals(TOK_DSEMI, token.getTokenType()); @@ -188,7 +198,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testSymbols4() { + public void testSymbols4() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer( "< << <<- <& <> > >> >| >&"); BjorneToken token = tokenizer.next(); @@ -213,7 +223,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testWords() { + public void testWords() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer("hello there"); BjorneToken token = tokenizer.next(); assertEquals(TOK_WORD, token.getTokenType()); @@ -225,7 +235,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testWords2() { + public void testWords2() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer( "hello\\ there\\\n friend"); BjorneToken token = tokenizer.next(); @@ -243,9 +253,20 @@ assertEquals("hello\\ there\\ friend", token.getText()); token = tokenizer.next(); assertEquals(TOK_END_OF_STREAM, token.getTokenType()); + + tokenizer = new BjorneTokenizer( + "hello\\\nthere\\\n friend"); + token = tokenizer.next(); + assertEquals(TOK_WORD, token.getTokenType()); + assertEquals("hellothere", token.getText()); + token = tokenizer.next(); + assertEquals(TOK_WORD, token.getTokenType()); + assertEquals("friend", token.getText()); + token = tokenizer.next(); + assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testWords3() { + public void testWords3() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer("'1 2' \"3 4\" `5 6`"); BjorneToken token = tokenizer.next(); assertEquals(TOK_WORD, token.getTokenType()); @@ -260,7 +281,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testWords4() { + public void testWords4() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer("'1 \"2\"' \"3\\\"4\""); BjorneToken token = tokenizer.next(); assertEquals(TOK_WORD, token.getTokenType()); @@ -272,7 +293,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testWords5() { + public void testWords5() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer("1<2>3&4;5|6)7"); BjorneToken token = tokenizer.next(); assertEquals(TOK_IO_NUMBER, token.getTokenType()); @@ -311,7 +332,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testRule1() { + public void testRule1() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer( "if then else elif fi for done while until " + "case { } ! do in esac"); @@ -351,7 +372,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testRule5() { + public void testRule5() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer( "if a a1 9a a_b a,b AB A=b"); BjorneToken token = tokenizer.next(RULE_5_CONTEXT); @@ -374,7 +395,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testRule6() { + public void testRule6() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer("if in do"); BjorneToken token = tokenizer.next(RULE_6_CONTEXT); assertEquals(TOK_WORD, token.getTokenType()); @@ -386,7 +407,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testRule7a() { + public void testRule7a() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer( "if then else elif fi for done while until " + "case { } ! do in esac a= a=b 1a=b =c"); @@ -434,7 +455,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testRule7b() { + public void testRule7b() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer( "if then else elif fi for done while until " + "case { } ! do in esac a= a=b 1a=b =c"); @@ -482,7 +503,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testRule8() { + public void testRule8() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer( "if then else elif fi for done while until " + "case { } ! do in esac a a_b a= a=b 1a=b =c"); @@ -534,7 +555,7 @@ assertEquals(TOK_END_OF_STREAM, token.getTokenType()); } - public void testRegress() { + public void testRegress() throws IncompleteCommandException { BjorneTokenizer tokenizer = new BjorneTokenizer("ls -l"); BjorneToken token = tokenizer.peek(RULE_7a_CONTEXT); assertEquals(TOK_WORD, token.getTokenType()); 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-02-09 16:04:03 UTC (rev 5015) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-10 14:23:53 UTC (rev 5016) @@ -8,6 +8,14 @@ <output>HI </output> </testSpec> + <testSpec title="continuation" command="test" runMode="AS_SCRIPT" rc="0"> + <script>#!bjorne + echo hello \ +mother + </script> + <output>hello mother +</output> + </testSpec> <testSpec title="$?" command="test" runMode="AS_SCRIPT" rc="0"> <script>#!bjorne true This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-12 12:22:28
|
Revision: 5017 http://jnode.svn.sourceforge.net/jnode/?rev=5017&view=rev Author: crawley Date: 2009-02-12 11:36:46 +0000 (Thu, 12 Feb 2009) Log Message: ----------- Implement 'case' compound statements. Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 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/CaseCommandNode.java trunk/shell/src/shell/org/jnode/shell/bjorne/CaseItemNode.java trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml Modified: trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 2009-02-10 14:23:53 UTC (rev 5016) +++ trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 2009-02-12 11:36:46 UTC (rev 5017) @@ -378,7 +378,7 @@ * @param pattern the pattern in shell syntax. * @return the corresponding regex as a {@link Pattern}. */ - public static Pattern compilePosixShellPattern(String pattern, int flags) { + public static Pattern compilePosixShellPattern(CharSequence pattern, int flags) { // This method needs to be really careful to avoid 'ordinary' characters // in the source pattern being accidentally mapped to Java regex // meta-characters. Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-10 14:23:53 UTC (rev 5016) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-12 11:36:46 UTC (rev 5017) @@ -1086,9 +1086,10 @@ return interpreter.fork(command, ios); } - public boolean patternMatch(CharSequence expandedWord, CharSequence pat) { - // TODO Auto-generated method stub - return false; + public boolean patternMatch(CharSequence text, CharSequence pat) { + int flags = PathnamePattern.EAGER | PathnamePattern.DEFAULT_FLAGS; + Pattern regex = PathnamePattern.compilePosixShellPattern(pat, flags); + return regex.matcher(text).matches(); } public String[] getArgs() { Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-02-10 14:23:53 UTC (rev 5016) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-02-12 11:36:46 UTC (rev 5017) @@ -579,10 +579,12 @@ private BjorneToken[] parsePattern() throws ShellSyntaxException { List<BjorneToken> pattern = new LinkedList<BjorneToken>(); while (true) { - int tt = tokens.next().getTokenType(); + BjorneToken token = tokens.next(); + int tt = token.getTokenType(); if (tt != TOK_WORD) { syntaxError("expected WORD in pattern", tt); } + pattern.add(token); if (tokens.peek().getTokenType() != TOK_BAR) { break; } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-02-10 14:23:53 UTC (rev 5016) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-02-12 11:36:46 UTC (rev 5017) @@ -56,14 +56,15 @@ @Override public int execute(BjorneContext context) throws ShellException { - int rc = -1; + int rc = 0; CharSequence expandedWord = context.expand(word.text); - for (CaseItemNode caseItem : caseItems) { + LOOP: for (CaseItemNode caseItem : caseItems) { for (BjorneToken pattern : caseItem.getPattern()) { CharSequence pat = context.expand(pattern.text); if (context.patternMatch(expandedWord, pat)) { - throw new ShellException("not implemented yet"); + rc = caseItem.getBody().execute(context); + break LOOP; } } } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CaseItemNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/CaseItemNode.java 2009-02-10 14:23:53 UTC (rev 5016) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/CaseItemNode.java 2009-02-12 11:36:46 UTC (rev 5017) @@ -42,11 +42,14 @@ StringBuffer sb = new StringBuffer(); sb.append("CaseItem{"); if (pattern != null) { - sb.append(",pattern="); + sb.append("pattern="); CommandNode.appendArray(sb, pattern); } if (body != null) { - sb.append(",body=").append(body); + if (pattern != null) { + sb.append(","); + } + sb.append("body=").append(body); } sb.append("}"); return sb.toString(); Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java 2009-02-10 14:23:53 UTC (rev 5016) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneParserTests.java 2009-02-12 11:36:46 UTC (rev 5017) @@ -122,9 +122,9 @@ public void test10() throws ShellException { assertEquals( "CaseCommand{nodeType=9,word=WORD{$1},caseItems=[" - + "CaseItem{,pattern=[],body=" + + "CaseItem{pattern=[WORD{a}],body=" + "SimpleCommand{nodeType=1,words=[WORD{ls},WORD{-l}]}}," - + "CaseItem{,pattern=[],body=" + + "CaseItem{pattern=[WORD{b}],body=" + "SimpleCommand{nodeType=1,words=[WORD{ls},WORD{-a}]}}]}", doTest("case $1 in ( a ) ls -l ;; b ) ls -a ; esac")); } 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-02-10 14:23:53 UTC (rev 5016) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-12 11:36:46 UTC (rev 5017) @@ -234,6 +234,49 @@ 1 </output> </testSpec> + <testSpec title="case ... esac" command="test" runMode="AS_SCRIPT" rc="0"> + <script>#!bjorne + case 1 in ( 1 ) echo hi mum ;; 2 ) echo bye mum ; esac + case 1 in 1 ) echo hi mum ;; 2 ) echo bye mum ; esac + case 2 in ( 1 ) echo hi mum ;; 2 ) echo bye mum ; esac + case 2 in ( 1 | 2 ) echo hi mum ;; 3 ) echo bye mum ; esac + case 2 in ( 1 | 2 ) echo hi mum ;; 3 ) echo bye mum ;; esac + case 3 in ( 1 | 2 ) echo hi mum ;; 3 ) echo bye ; echo mum ; esac + </script> + <output>hi mum +hi mum +bye mum +hi mum +hi mum +bye +mum +</output> + </testSpec> + <testSpec title="case ... esac multi-line" command="test" runMode="AS_SCRIPT" rc="0"> + <script>#!bjorne + case 1 in + ( 1 ) echo hi mum ;; + 2 ) echo bye mum + esac + case 1 in + 1 ) echo hi mum ;; + 2 ) echo bye mum ; esac + case 2 in ( 1 ) echo hi mum ;; + 2 ) echo bye mum + esac + case 2 in ( 1 | 2 ) echo hi mum ;; + 3 ) echo bye mum ;; esac + case 2 in ( 1 | 2 ) echo hi mum ;; + 3 ) echo bye mum ;; + esac + </script> + <output>hi mum +hi mum +bye mum +hi mum +hi mum +</output> + </testSpec> <testSpec title="${...} expansions" command="test" runMode="AS_SCRIPT" rc="0"> <script>#!bjorne A=cat This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |