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

replace \$\$ \* causes micro to freeze #2440

Open
andrejpodzimek opened this issue May 30, 2022 · 3 comments
Open

replace \$\$ \* causes micro to freeze #2440

andrejpodzimek opened this issue May 30, 2022 · 3 comments

Comments

@andrejpodzimek
Copy link

andrejpodzimek commented May 30, 2022

Description of the problem or steps to reproduce

  1. Open a document that contains $$ at least once. Or open an empty one and type $$ into it.
  2. Press Ctrl+E and input replace \$\$ \*. The editor will freeze.

Specifications

Commit hash: micro -version doesn’t show any hash. It says “Version: 2.0.8”.
OS: Linux
Terminal: Guake, Yakuake, Konsole

@andrejpodzimek andrejpodzimek changed the title replace \$\$ \* cause micro to freeze replace \$\$ \* causes micro to freeze May 30, 2022
@dmaluka
Copy link
Collaborator

dmaluka commented Mar 17, 2024

It doesn't freeze actually, it just doesn't replace the $$, instead it "replaces" the empty space at the end of the line, i.e. just inserts * at the end of the line. The dollar signs remain unreplaced no matter how many times the user says "yes", so it might seem to the user that nothing happens.

Unfortunately this is a "feature, not a bug". The $ is interpreted as the end of the line, and escaping it with a single \ doesn't help, since this \ is already taken by the command-line argument parser (i.e. what the regex parser receives as an input is $$, not \$\$).

To solve this, escape with double backslashes (\\):

replace \\$\\$ \*

or use single quotes:

replace '\$\$' \*

@dmaluka
Copy link
Collaborator

dmaluka commented Mar 17, 2024

Unfortunately this is a "feature, not a bug".

Actually, since this isn't the first or the last time when this "feature" is causing a lot of confusion, perhaps we should consider finally fixing it, by making an exception for the 1st argument of the replace command: parse it directly with the regex parser, bypassing the command argument parser.

@JoeKar
Copy link
Collaborator

JoeKar commented Mar 17, 2024

Will it then still work with single- or double quotes given around the pattern?
Just thinking about it, since it's somehow common to us a kind of quotes with egrep and sed too. But on the other hand it's most probably not sufficient to add exactly this to the documentation.

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

No branches or pull requests

3 participants