|
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.
|