grc icon indicating copy to clipboard operation
grc copied to clipboard

regex command patterns in grc.conf are wrong

Open flux242 opened this issue 5 years ago • 5 comments

lets take 'du' as an example:

# du
(^|[/\w\.]+/)du\s?
conf.du

what you actually wanted was:

(^|^[/\w\.]+/)du\s?

it's because otherwise if I'd issue

du -sh ./dig.txt

the conf.dig would be used to colorize du output because its regex comes before the one for 'du'

Still, having '(^|^[/\w.]+/)' won't help because neither './du' nor '/usr/bin/du' are aliased. So if I use '/usr/bin/du -sh *' then no grc be called at all.

flux242 avatar Feb 07 '20 07:02 flux242

Just to clarify, './du' and '/usr/bin/du' (and also '\du') are standard ways to bypass aliases, at least on sh-compatible shells, so those forms shouldn't actually be matched by the regex.

I agree with your other point though.

richarson avatar Mar 14 '20 20:03 richarson

Just to clarify, './du' and '/usr/bin/du' (and also '\du') are standard ways to bypass aliases, at least on sh-compatible shells, so those forms shouldn't actually be matched by the regex.

that's what I was trying to say. To my opinion proper regex for du case would be just

^du\s?

flux242 avatar Mar 15 '20 02:03 flux242

Just to clarify, './du' and '/usr/bin/du' (and also '\du') are standard ways to bypass aliases, at least on sh-compatible shells, so those forms shouldn't actually be matched by the regex.

Yes, you are right. When starting with grc, I was trying to be as inclusive as possible, which was not the best idea.

that's what I was trying to say. To my opinion proper regex for du case would be just

^du\s?

Or ^du\b, otherwise it will match any command beginning with du....

garabik avatar Jul 19 '20 12:07 garabik

hello, I've seed that you've changed the du case in the devel branch. But it's generic problem that is applied for all commands, not just du!

flux242 avatar Nov 30 '20 05:11 flux242

Re-thinking the issue, I left the entries with the paths (while fixing superfluous matching). After all, since it is not aliased, it will only apply if you deliberately invoke grc (with grc /usr/bin/du) and then you probably want it to apply...

garabik avatar Dec 29 '20 15:12 garabik