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

grcat hangs when using replace #103

Closed
Jeansen opened this issue Jul 16, 2018 · 2 comments
Closed

grcat hangs when using replace #103

Jeansen opened this issue Jul 16, 2018 · 2 comments

Comments

@Jeansen
Copy link

Jeansen commented Jul 16, 2018

I have a log file in which I would like to replace , with \n, .

So, I put the following in a configuration file my.config:

regexp=(,)
replace=\n,

and call it like grcat my.config < some_logifle.

But this only results in high cpu load and grcat does not respond. I have to kill the process by force.

This also happens with things like:

regexp=,
replace=\n,

or:

regexp=(,)
replace=\1\n

or simply:

regexp=(,)
replace=\1

This works, though:

regexp=(,)
replace=\n

python --version gives me:
Python 2.7.15

@garabik
Copy link
Owner

garabik commented Dec 25, 2018

It is clear why this happens - the replacement contains comma, so the regular expression matches the line again, replaces the comma with \n,, matches again, replaces the comma again to obtain \n\n,, etc... Eventually the python interpreter would run out of memory.

This is by design, replacement does not advance the position in the line, so that any subsequent colourifying rules/matches can be applied against the new line.

In ae79db5 I have applied a change that stops replacing after the first successful replace, so it should be fixed.

@garabik garabik closed this as completed Dec 25, 2018
@Jeansen
Copy link
Author

Jeansen commented Dec 26, 2018

Oh, great. I will check it out, soon. Thanks!

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

2 participants