Closed greenfork closed 3 months ago
From the documentation: "The Callable will be called for each file (in sorted order) and each line of the file, giving the line (including its line ending)".
So the .match(/a$/)
would not match, so Empty
was being returned always. So you would indeed need a /a$$/
as the pattern.
The reason the \n
is included, is that you may want to remove that to merge lines.
Now, whether that is a sensible default, I would have to think about that.
We could let it default to not including, and if you want them, specify --with-line-endings
. Hmmmm...
Oh, interesting, the documentation in rak --help=content
does not mention that. I will consult the docs at https://raku.land/zef:lizmat/App::Rak too.
I've just released 0.3.12 (which should be visible there in a few minutes). You should be able to download it now already (might need a zef --update
).
This will default to not producing line endings, specify --with-line-endings
if you do want them.
I also added a mention to the --help
page.
Works on my side, thank you!
If I have this file in
file.txt
(with newline at the end):and I run this command
then I correctly get the match. But when I run the same command with
--modify-files
then no files are processed. This can be fixed by changing regex from
/a$/
to/a$$/
and replacement to"a\n"
to save the newline:The fact that searching and modifying works differently regarding
$
was confusing to me, maybe it is worth fixing or clarifying.