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
{code}
public String readLine(String prompt, Character mask) throws IOException {
        boolean highlightDisabled = reader.isSet(LineReader.Option.DISABLE_HIGHLIGHTER);
        try {
            if (!highlightDisabled) {
                reader.setOpt(LineReader.Option.DISABLE_HIGHLIGHTER);
            }
            reader.getVariables().put(LineReader.DISABLE_HISTORY, Boolean.TRUE);
            return reader.readLine(prompt, mask);
        } finally {
            if (!highlightDisabled) {
                reader.setOpt(LineReader.Option.DISABLE_HIGHLIGHTER);
            }
            reader.getVariables().remove(LineReader.DISABLE_HISTORY);
        }
    }
{code}

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:
{code}
reader.readLine(...);
String line = reader.getParsedLine().line();
{code}

> 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
(v6.4.14#64029)

Mime
View raw message