|
From: <cr...@us...> - 2009-07-23 15:26:03
|
Revision: 5619
http://jnode.svn.sourceforge.net/jnode/?rev=5619&view=rev
Author: crawley
Date: 2009-07-23 15:26:00 +0000 (Thu, 23 Jul 2009)
Log Message:
-----------
Bug fix: the value part of an assignment needs to be dequoted after
expansions have been performed.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-22 14:42:31 UTC (rev 5618)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-07-23 15:26:00 UTC (rev 5619)
@@ -966,7 +966,7 @@
}
- private String variable(String parameter) throws ShellSyntaxException {
+ String variable(String parameter) throws ShellSyntaxException {
if (BjorneToken.isName(parameter)) {
VariableSlot var = variables.get(parameter);
return (var != null) ? var.getValue() : null;
@@ -1124,7 +1124,7 @@
}
String name = assignment.substring(0, pos);
String value = dollarBacktickExpand(assignment.substring(pos + 1)).toString();
- this.setVariable(name, value);
+ this.setVariable(name, dequote(value).toString());
}
}
}
@@ -1363,14 +1363,4 @@
return variables.keySet();
}
- public String getVariable(String name) {
- VariableSlot slot = variables.get(name);
- if (slot == null) {
- return "";
- } else if (slot.getValue() == null) {
- return "";
- } else {
- return slot.getValue();
- }
- }
}
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-07-22 14:42:31 UTC (rev 5618)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-07-23 15:26:00 UTC (rev 5619)
@@ -271,8 +271,12 @@
@Override
public String getPrompt(CommandShell shell, boolean continuation) {
- String res = context.getVariable(continuation ? "PS2" : "PS1");
- return (res == null) ? "$ " : expandPrompt(res);
+ try {
+ String res = context.variable(continuation ? "PS2" : "PS1");
+ return (res == null) ? "$ " : expandPrompt(res);
+ } catch (ShellSyntaxException ex) {
+ return "$ ";
+ }
}
private String expandPrompt(String prompt) {
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-07-22 14:42:31 UTC (rev 5618)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-07-23 15:26:00 UTC (rev 5619)
@@ -54,6 +54,22 @@
1
</output>
</testSpec>
+ <testSpec title="quote handling" command="test" runMode="AS_SCRIPT" rc="0">
+ <script>#!bjorne
+echo ${PS1}+
+PS1="] "
+echo ${PS1}+
+PS1='] '
+echo ${PS1}+
+PS1=]\
+echo ${PS1}+
+</script>
+ <output>$ +
+] +
+] +
+] +
+</output>
+ </testSpec>
<testSpec title="``" command="test" runMode="AS_SCRIPT" rc="0">
<script>#!bjorne
A=1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|