Use a more simple mechanism for retrieving the prompt instead of evaluating a command
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@804956 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java
index 126c51a..c682013 100644
--- a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java
@@ -24,6 +24,8 @@
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Properties;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
@@ -41,8 +43,7 @@
{
public static final String PROMPT = "PROMPT";
- public static final String DEFAULT_PROMPT =
- "\"\u001B\\[1m${USER}\u001B\\[0m@${APPLICATION}> \"";
+ public static final String DEFAULT_PROMPT = "\u001B[1m${USER}\u001B[0m@${APPLICATION}> ";
private CommandSession session;
private ConsoleReader reader;
@@ -174,9 +175,13 @@
} catch (Throwable t) {
prompt = DEFAULT_PROMPT;
}
- Object v = session.execute(prompt);
- if (v != null) {
- prompt = v.toString();
+ Matcher matcher = Pattern.compile("\\$\\{([^}]+)\\}").matcher(prompt);
+ while (matcher.find()) {
+ Object rep = session.get(matcher.group(1));
+ if (rep != null) {
+ prompt = prompt.replace(matcher.group(0), rep.toString());
+ matcher.reset(prompt);
+ }
}
return prompt;
} catch (Throwable t) {