Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 89887 invoked from network); 17 Aug 2009 12:52:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Aug 2009 12:52:11 -0000 Received: (qmail 65593 invoked by uid 500); 17 Aug 2009 12:52:17 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 65524 invoked by uid 500); 17 Aug 2009 12:52:17 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 65493 invoked by uid 99); 17 Aug 2009 12:52:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Aug 2009 12:52:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Aug 2009 12:52:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CC98F238886C; Mon, 17 Aug 2009 12:51:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r804956 - /felix/trunk/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java Date: Mon, 17 Aug 2009 12:51:48 -0000 To: commits@felix.apache.org From: gnodet@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090817125148.CC98F238886C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gnodet Date: Mon Aug 17 12:51:48 2009 New Revision: 804956 URL: http://svn.apache.org/viewvc?rev=804956&view=rev Log: Use a more simple mechanism for retrieving the prompt instead of evaluating a command Modified: felix/trunk/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java Modified: felix/trunk/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java?rev=804956&r1=804955&r2=804956&view=diff ============================================================================== --- felix/trunk/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java (original) +++ felix/trunk/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java Mon Aug 17 12:51:48 2009 @@ -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) {