malxau/yori

`repl` and `hilite` hang if empty string is passed

Closed this issue · 3 comments

ver | repl "" "" hangs
ver | hilite -c "" green does not hang and colors the entire output with specified color
ver | hilite -c "" green -m hangs

Thanks for letting me know. As you've probably surmised, this happens because searching for an empty string matches at the beginning of the string, and continues matching the same offset without making progress.

I think the best fix for the two tools is a bit different though:

  • For repl, it doesn't make much sense to replace an empty string with something, so this command should fail.
  • For hilite, it does make some sense to highlight the entire line with an empty string, which would match all lines allowing them to be displayed in color. However, highlighting a specific term that is empty makes no sense. Rather than fail completely, I think this should just not match and continue executing.

I'll push some changes for these over the next couple days.

I pushed commit 1d494c2 and 67405c6 for these. Please let me know if you encounter any issues after these commits.

1.60 is in stable now. Please reopen or file another issue if there's still something broken or missing here.