Open andrejpodzimek opened 2 years ago
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 '\$\$' \*
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.
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.
Description of the problem or steps to reproduce
$$
at least once. Or open an empty one and type$$
into it.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