4 ms·
Unfortunately not. macOS comes with violently outdated FreeBSD coreutils, for the GPLv3 situation. Though the default shell was recently changed to zsh from Bas
by xcdzvyn 3y ago
Unfortunately not. macOS comes with violently outdated FreeBSD coreutils, for the GPLv3 situation. Though the default shell was recently changed to zsh from Bash 3.2 from 2007.
- yjftsjthsd-h 3y agoRight, which is why I thought it was common for people to install the operating system, then immediately use macports or homebrew to go get the GNU coreutils and a modern version of bash because the BSD versions are less friendly. (Thus continuing and extremely long tradition of layering GNU over the vendor tools; ex. Sun had their own tools, but everyone liked the GNU versions better.)
- stephenr 3y agoPeople do it, but why you would when zsh is right there, is beyond me. Possibly the same type of people that target bash specifically in shell scripts I guess.
- matheusmoreira 3y agoWhat's wrong with bash though? Targeting bash specifically has massively improved my productivity and decreased the incidence of easily avoidable mistakes. Portable POSIX shell scripting is hell on earth but bash scripting with shellcheck can be surprisingly pleasant. I had the same experience with portable makefiles and GNU Make. For example, I managed to create a surprisingly good test suite with bash and the rest of the GNU coreutils: https://github.com/lone-lang/lone/blob/master/scripts/test.bash https://github.com/lone-lang/lone/blob/master/scripts/test.b... It even runs in parallel. Submitted a patch to coreutils to implement the one thing it couldn't test, namely the argv[0] of programs. I should probably go check if they merged it...
- stephenr 3y ago> Portable POSIX shell scripting is hell on earth but bash scripting with shellsheck can be surprisingly pleasant. Assuming you meant `shellcheck`: you know it works for POSIX compatible shell too right? What's wrong with bash is that people invariably end up requiring features that aren't available in some deployed version, and then you've lost a lot of the benefit of writing in shell in the first place. Similar to shellcheck, shunit2 works just fine for running unit tests in posix compatible shell.
- matheusmoreira 3y ago> Assuming you meant `shellcheck` I did. Edited my comment, thanks. I don't know why I'm so prone to that particular typo. My shell history is full of it. > What's wrong with bash is that people invariably end up requiring features that aren't available in some deployed version, and then you've lost a lot of the benefit of writing in shell in the first place. But I've gained quite a lot too. Bash has associative arrays. I just can't go back to a shell that doesn't have that. Shell scripting makes it simple to manage processes and the flow of data between them. It's the best tool for the job in these cases. So there are still reasons for scripting the shell even if one is willing to sacrifice portability.
- DonHopkins 3y agoI just can't believe it's 2023 and we're actually praising a shell for having arrays and dictionaries. Or that there are still multiple shells in use that don't. Or that people still ask questions like "What's wrong with bash though?" with a straight face, as if they don't know. Now how long are we going to have to wait until somebody invents a way to do named parameters? That will revolutionize the computer industry! I guess it's way to much to ask for a built-in json or yaml parser, all we can hope for is maybe a stringly typed sax callback based xml parser after another 20 years from now, because dom objects in a shell would be heretical and just so unthinkably complicated. Why are people so afraid to just use Python? Shell scripting and cobbling together ridiculously inefficient incantations of sed, awk, tr, test, expr, grep, curl, and cat with that incoherently punctuated toenail, thumbtack, and asbestos chewing gum syntax that inspired perl isn't ever any easier than using Python, especially when you actually need to use data structures, named function parameters, modules, libraries, web apis, xml, json, or yaml.
- jval43 3y agoAgreed. If you don't test your script in other shells and on other platforms, why advertise compatibility. And not just the script, but also the programs called. I got burned by supposedly "portable" scripts by the whole Ubuntu dash disaster, and again when I started using Mac OS X, and then again once I used Cygwin and msys2 on Windows. I do keep portability in mind when writing shell scripts to ease porting later, but without testing there's really no way to be sure "/bin/sh" is right. And some of the Bash features such as arrays are legitimately useful.
- yjftsjthsd-h 3y agoI favor POSIX sh myself, but BASH sits on a happy medium of portability and features; zsh might well win on features, but Darwin is the only OS I know of that installs it by default, where BASH is nearly universally installed by default on Linux distros and still has considerably more features than POSIX /bin/sh.
- stephenr 3y agoFor scripts I'm with you on POSIX. I was referring specifically to interactive use: ie why someone would install bash to use as their shell, when zsh is already there.
- yjftsjthsd-h 3y agoI use bash mostly out of habit and because it's installed by default, but also because zsh had some sort of incompatibility with some of my aliases that I never got around to debugging.
- _ZeD_ 3y agoFWIW that's exactly what I've done
- xcdzvyn 3y agoOh sorry, I interpreted your comment as asking whether Darwin installed GNU coreutils itself in some roundabout, very-expensive-lawyer sanctioned manner :)
- pram 3y agoThe BSD licensed stuff isn't outdated, it's actually directly from FreeBSD 14.0 afaict. ZSH is current (5.9) in Sonoma for example.