Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong escaping of backslash symbol - first backslash in sequnce getting swallowed #74

Closed
iamtakingiteasy opened this issue Feb 4, 2013 · 4 comments

Comments

@iamtakingiteasy
Copy link

When you do [ConsoleReader instance].readLine() the following oddity with backslashes exists:

\ - single backslash is simply ignored
\ - two backslashes is represented as single backslash
\\ - three backslashes is represented as two backslashes \
etc

@iamtakingiteasy
Copy link
Author

The same thing happens to history items

@iamtakingiteasy
Copy link
Author

The problem is located somewhere in .exapndEvents() function; setting consoleReader.setExpandEvents(false) resolves the issue.

The actual place where problem is located:

    if (expandEvents) {
        str = expandEvents(str);
        historyLine = str.replaceAll("\\!", "\\\\!");
    }

of .finishBuffer() function.

@koen-serneels
Copy link

We are having the same problem.
Setting expandEvents to "false" does indeed solve it, but, this also disables the use of bash alike "event designators."
For example, entering "!!" re-executes the last command from history. If you turn off expandEvents then "!!" will be interpreted as a command by itself rather then a event designator.
So I think a fix would still be welcome here:)

@gnodet
Copy link
Member

gnodet commented Apr 5, 2013

The purpose of escaping is to allow characters used in event designators to be used nonetheless.
So I guess any fixes will need to go into the expandEvents() method.
The goal is to have a behavior similar to bash and the gnu readline, so all fixes are welcomed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants