Comment by nunez
2 years ago
Switching to bsd grep is one of the first things I do on a new macOS install. The builtins are old as hell!
2 years ago
Switching to bsd grep is one of the first things I do on a new macOS install. The builtins are old as hell!
I just install GNU grep and add it to PATH so I get the same version as on Linux:
https://formulae.brew.sh/formula/grep
Same, but BSD feel is also old as hell. Ripgrep all the way.
rg is massive “The UNIX programming environment” vibes.
Lightning fast.
Sane defaults.
Obviously rust too.
Most used tool on my computer.
Also see fd, sd, bat, lsd
1 reply →
Any reason for picking the BSD variants of usedland tooling over the GNU ones?
Can't speak for everyone, but for me... familiarity, hackability, simplicity, standards compliance.
GNU coreutils deviate from POSIX in a number of instances.
GNU coreutils are also verbose and potentially overengineered. Compare GNU ls.c (4726 LOC) to FreeBSD ls.c (1030 LOC), for example. Even if you include the other BSD source files used in ls, the FreeBSD version is still half the size of the GNU version. GNU grep is over 3000 LOC, whereas the FreeBSD version is 724.
Who cares about posix? It's not the 2000's anymore. Solaris is dead. HP-UX is dead. Were you worried that someday you might have to port your shell script to AIX?
GNU and Linux won. The only BSD environment is macOS, and if you put GNU on macOS, then the only thing I can think of that's worth a mention is alpine and busybox containers, but at that point it feels like we're just grasping at straws.
1 reply →
> GNU grep is over 3000 LOC, whereas the FreeBSD version is 724.
Where are you getting that number from? Because I have a bit over 1,500 lines in usr.bin/grep (code only, excluding comments and blanks) vs. 3,900 for GNU grep.
Also you can't compile bsdgrep with just POSIX libc (such as musl) since it relies on some extensions (specifically: REG_STARTEND). So if you're looking for POSIX_ME_HARDER then bsdgrep isn't actually the right place.
3 replies →
What kinds of patches have you made to the BSD coreutils programs that you use?
4 replies →
Isn't that because GNU grep has more features than FreeBSD grep? Had to do a complex regex capturing to rewrite recently (automatic help based on Makefile command comments in a specific format), and having to have compatibility with FreeBSD grep was the main reason I couldn't do it with grep only and had to resort to Perl.
If anyone is curious, this is the resulting Perl oneliner:
Isn't bsd grep very slow? I remember reading "why gnu grep is fast": https://lists.freebsd.org/pipermail/freebsd-current/2010-Aug...
Honestly picking programs based on lines of source code where fewer is better is quite silly. Better algorithms generally have more code, not less. Unless you're doing embedded work it essentially doesn't matter how "big" programs are.
2 replies →
That article is about FreeBSD's grep.
Ofc I meant GNU grep, not BSD grep. My bad!
I can understand shipping the old stuff because you don't give a fuck, but why on earth are they .. patching them. Jesus.
The explicit stated reason is to avoid copyleft.
Up to date BSD code would still avoid copyleft so that is not a valid explanation.
3 replies →