5 ms·
I'm a big fan of not posix but instead modern bash and to all the complainers about dash and ash, I say "tough cookies". Bash has arithmetic, dictionaries, reg
by kristopolous 4y ago
I'm a big fan of not posix but instead modern bash and to all the complainers about dash and ash, I say "tough cookies".
Bash has arithmetic, dictionaries, regex matching, nice string manipulation, co-processes, TCP pipes built in, it's pretty nice.
However, bash has very low tolerance for incompetency. It's a brutal friend. It's cooking dinner with a pocket knife. You gotta actually read the docs and be sincere in your studies.
I was around when supporting Solaris, HPUX, AIX, and Irix was a real concern. Those times sucked and those platforms are so minor I stopped caring about them except for enthusiast projects many years ago. (And I still actually have an hpux machine)
Sometimes I'll even use zsh. It can even do floating point.
Here's some example of a modern tool I have written for a subject I call "music discovery"
https://github.com/kristopolous/music-explorer/tree/master/tools https://github.com/kristopolous/music-explorer/tree/master/t...
You'll see many languages in there but you won't see posix sh. It's slow, it's clunky, it's a pain in the ass.
If you don't like my practice then I guess don't use it. I've been using/developing these particular tools nearly every day for over 3 years and it works well for me.
I'm not going to say bash is awesome but it's pretty great for programming.
I use zsh as my interactive shell though, it's miles ahead of bash in that department. Watching people who really know what they're doing in zsh is a total mindfuck.
- User23 4y ago> I was around when supporting Solaris, HPUX, AIX, and Irix was a real concern. Back in the 90s it was surprising to not find gnu userspace installed on the systems I used.
- jkmcf 4y agoBack in the 90s, Solaris was the big hold out -- IRIX and HPUX both came with at least a subset. First thing I had to do on Solaris was install the GNU tools, and, thankfully, eventually there were packages to manage that installation.
- kristopolous 4y agoAbout 1/3 of the debug sessions involved looking at the screen peeved going "yes, obviously I meant gsed and ggrep you dumbass." You go through the man page of the vendor supplied version like "What do you mean you don't support feature x? This can't be real. I swear I'm being recorded right now. A bunch of people are sitting around a large conference table in mountain view right now laughing at my pain" Eventually I just read them as parody. Things like this can be really funny if you allow them to be.
- nailer 4y agoRemember how Solaris would show disk usage in … IIRC multiples of 512K? And the awful package manager? And all they’d do was talk about kernel debugging like that was a daily activity people needed help with.
- gattilorenz 4y ago> IIRC multiples of 512K You mean it showed it measured in blocks? If so, that’s been the standard for a long time and not only on Solaris :)
- nailer 4y agoYes I do. What an awful standard.
- gattilorenz 4y agoNot handy for "human comprehension", but it has its reasons, and was more important back then when space was really scarce: https://unix.stackexchange.com/questions/120311/why-are-there-so-many-different-ways-to-measure-disk-usage https://unix.stackexchange.com/questions/120311/why-are-ther...
- kristopolous 4y agoI'm not going to throw shade on earlier eras of computing. I study them intensely. However, I will throw shade on pegging things to those eras when everyone else has moved on. It'd be like having to grapple with near and far pointers still because that was a reality of the 16-bit world. I remember them, it was a brilliant system for the limitations but they've been gone for 25 or so years and good riddance. They were also bastards. Also when I see these things, it's like I've been in some kind of mythical suppressed memory therapy as these horrid events from my past come forth to haunt me again. One man's competency is another man's post traumatic disorder
- cleanchit 4y ago> It can even do floating point. Is this a bait post.
- chasil 4y agoDash is 4x faster and 10x smaller than Bash. Bash's own manual page concludes that it's "to big and too slow." I have applications where I need those properties, and I am not shy in selecting the correct tool. Bash's POSIX mode also does some wacky things when a script transitions in/out that encourage me to avoid it. https://unix.stackexchange.com/questions/148035/is-dash-or-some-other-shell-faster-than-bash https://unix.stackexchange.com/questions/148035/is-dash-or-s...
- ever1337 4y agoI think the real point is that most of the time when someone writes a bashism, it's unnecessary. You don't really lose anything 99% of the time by writing posix shell. If you need bash, write bash, and just change the shebang.
- bccdee 4y agoI think real arrays are the exception to this rule. They're the only non-posix shell feature I use consistently. Otherwise, whenever you want to gather a list of strings or filenames and then iterate through them, you need to worry about delimiters and splitting and parsing and IFS and that's simply not worth the dubious benefit of not including a bash shebang. If you really need to run the script on alpine, just install bash. If you're really space-constrained, then sure, go back and refactor the arrays into newline-delimited strings or whatever, but I've never had to do that and I doubt I ever will. Getting to use arrays means my scripts can avoid dealing with the horrible quirks of shell tokenization, and that's 100% worth it to me.
- jjgreen 4y agoThe number of times I have seen this: #!/usr/bin/bash some-other-program -c -x $1
- lelandfe 4y ago> people who really know what they're doing in zsh Any examples of cool stuff you can do in zsh?
- steponlego 4y agoIf you're chucking away POSIX sh just go all the way and use Perl.