logoalt Hacker News

tmtvltoday at 1:26 PM6 repliesview on HN

I would argue that grep-like tools which read .gitignore violate the Principle of Least Astonishment (POLA). It would be fine if there were a --ignore flag to enable such functionality, but defaulting to it just feels wrong to me. Obviously smarter people than I disagree, but my dumdum head just feels that way.


Replies

TallGuyShorttoday at 2:30 PM

> Obviously smarter people than I disagree, but my dumdum head just feels that way.

That's absolutely not it. What you're describing is part of the UNIX philosophy: programs should do one thing and do it well, and they should function in a way that makes them very versatile and composable, etc.

And that part of the philosophy works GREAT when everything follows another part of the philosophy: everything should be based on flat text files.

But for a number of reasons, and regardless of whatever we all think of those reasons, we live in a world that has a lot of stuff that is NOT the kind of flat text file grep was made for. Binary formats, minified JS, etc. And so to make the tool more practical on a modern *nix workstation, suddenly more people want defaults that are going to work on their flat text files and transparently ignore things like .git.

It's just that you've showed up to an wildly unprincipled world armed with principles.

rjzzleeptoday at 1:36 PM

Back in the day I would have agreed with you, but ever since there is js everywhere you end up with minified js that megabytes big and match everything. I still have muscle memory with `grep -r` and it almost always ends up with some js file, that I didn't know exists ruining the moment.

gregwtmtnotoday at 1:50 PM

I have to agree here. I love ripgrep, but at times I've had to go back to regular grep because I couldn't figure out what it was ignoring and why, and there were far too many settings to figure it out.

show 1 reply
justin66today at 2:22 PM

Agreed. It's a footgun.

carlosnevestoday at 1:54 PM

An `--ignore-file=` flag would be nice I guess:

--ignore-file=.ignore

--ignore-file=.gitignore

--ignore-file=.dockerignore

--ignore-file=.npmignore

etc

but then, assuming all those share the same "ignore file syntax/grammar"...

show 1 reply
keyboredtoday at 1:39 PM

It’s the kind of thing that maybe makes sense today. Less likely to make sense twenty years from now though.

But that’s the kind of problem that only successful things have to worry about.

show 1 reply