karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Nodet (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KARAF-5382) Karaf shell session.readLine consumes backslashes
Date Tue, 19 Sep 2017 10:00:01 GMT

    [ https://issues.apache.org/jira/browse/KARAF-5382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16171440#comment-16171440

Guillaume Nodet commented on KARAF-5382:

Could you try something like
public String readLine(String prompt, Character mask) throws IOException {
        boolean highlightDisabled = reader.isSet(LineReader.Option.DISABLE_HIGHLIGHTER);
        try {
            if (!highlightDisabled) {
            reader.getVariables().put(LineReader.DISABLE_HISTORY, Boolean.TRUE);
            return reader.readLine(prompt, mask);
        } finally {
            if (!highlightDisabled) {

This should disable the highlighter and history.
As for backslashes, they are considered as an escaping character.  A workaround to get the
raw line is the following:
String line = reader.getParsedLine().line();

> Karaf shell session.readLine consumes backslashes
> -------------------------------------------------
>                 Key: KARAF-5382
>                 URL: https://issues.apache.org/jira/browse/KARAF-5382
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-shell
>            Reporter: Tom Quarendon
> I don't know what the intended use case is for session.readLine, but the behaviour w.r.t
backslashes is odd.
> I use is to prompt for a password from the user. So in an action, call session.readLine("prompt",
'*'). However, if the user's password contains a backslash, readLine doesn't return what the
user typed, which is mighty confusing. 

This message was sent by Atlassian JIRA

View raw message