4 ms·
Switching to bsd grep is one of the first things I do on a new macOS install. The builtins are old as hell!
by nunez 3y ago
Switching to bsd grep is one of the first things I do on a new macOS install. The builtins are old as hell!
- cpressland 3y agoAny reason for picking the BSD variants of usedland tooling over the GNU ones?
- torstenvl 3y agoCan'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.
- burntsushi 3y agoWhat kinds of patches have you made to the BSD coreutils programs that you use?
- torstenvl 3y agohttps://github.com/torstenvl/betterls https://github.com/torstenvl/betterls To be fair, one of these two flags comes built in with GNU ls, but using GNU ls comes with the downside of losing support for macOS extended attributes (and GNU ls doesn't have --group-dots-extra-first).
- Pet_Ant 3y agoI mean that seems like a simple patch to upstream if it’s a real deal breaker for you….
- torstenvl 3y agoOr I can just continue being happy hacking on simple code bases. It is not my responsibility to upstream anything. If you feel like it should be upstreamed, my additions are open source. Go for it.
- corbezzoli 3y agoYou make it sound like just because you want and write something it will get merged into a project. It doesn’t work like that. Maintainers have a million reasons to say no and I have one reason to just use a different tool instead.
- jppittma 3y agoWho 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.
- torstenvl 3y ago> Who cares about posix? ... GNU and Linux won. Well, I do :) That's why I said I was only speaking for myself. As long as we have a rich variety of free and open source software to choose from, I think we've all won.
- arp242 3y ago> 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.
- burntsushi 3y agoThey probably also aren't counting the lines of whatever is in gnulib that GNU grep uses.
- arp242 3y agoPlease don't make this thread NSFW.
- adrian_b 3y agoI suppose that only the lines of usr.bin/grep/grep.c have been counted by the previous poster. The number of lines is obviously version-dependent. Looking at the file mentioned above on a FreeBSD system to which I happen to be connected, I see 805 lines, including the comments and blanks, while all the source files total 2027 lines, also including the comments and blanks.
- globular-toast 3y agoHonestly 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.
- tm-guimaraes 3y agoIt matters if you want to hack on them
- globular-toast 3y agoTrue, to some extent. Being "big" doesn't necessarily mean it's hard to hack on, though. Emacs is huge and probably the easiest thing to hack on.
- vocworker 3y agoIsn't bsd grep very slow? I remember reading "why gnu grep is fast": https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html https://lists.freebsd.org/pipermail/freebsd-current/2010-Aug...
- sofixa 3y agoIsn'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: perl -WE 'printf ("COMMAND;DESCRIPTION;USAGE\n");while (my $line = <>) { $line =~ /^(.*):\s#\s(.*)\[Usage\s`(.\*)`]/ && printf("$1;$2;$3\n")};' Makefile | column -c "3" -s ";" -t
- orf 3y agoSame, but BSD feel is also old as hell. Ripgrep all the way.
- stefan_ 3y agoI can understand shipping the old stuff because you don't give a fuck, but why on earth are they .. patching them. Jesus.
- callalex 3y agoThe explicit stated reason is to avoid copyleft.
- epcoa 3y agoUp to date BSD code would still avoid copyleft so that is not a valid explanation.
- jahav 3y agoMaybe when uutils ship their gnu compatible version(deviations from GNU are considered bugs), macos will update. MIT, Rust, active development... Maybe in few years.
- vbezhenar 3y agomacOS Ventura ships zsh 5.9 which is latest version and was released 2022-05-14. Not sure about grep, but at least some of their unix components are up to date.
- deleted 3y ago[deleted]
- arp242 3y agoThat article is about FreeBSD's grep.
- silverwind 3y agoI just install GNU grep and add it to PATH so I get the same version as on Linux: https://formulae.brew.sh/formula/grep https://formulae.brew.sh/formula/grep
- nunez 3y agoOfc I meant GNU grep, not BSD grep. My bad!