5 ms·
I agree with most of this, my biggest issue is how hard it is for me to recall any moderately complex shell syntax (or the slightly different Makefile syntax).
by alanbernstein 2y ago
I agree with most of this, my biggest issue is how hard it is for me to recall any moderately complex shell syntax (or the slightly different Makefile syntax). LLMs largely solve that for me.
- throwaway458864 2y agoThe bash man page is my bible. It's dense and long but it always has the answers, you just gotta know where to look.
- nocombination 2y agoWhen people mention `bash` it's immediately a code smell. In order to write portable shell scripts, it must be only POSIX `sh`. If the need ever arises for a more complex data structure, typically I jump into AWK since it's also POSIX compliant. Here's a note from the Ubuntu recommendation: https://wiki.ubuntu.com/DashAsBinSh https://wiki.ubuntu.com/DashAsBinSh
- 10000truths 2y agoI've never been in a situation where I had to care. Bash is everywhere, it's a de facto standard of its own. Even a lot of buildroot and Alpine based Linux deployments, which don't come with bash by default, usually have bash added to them.
- Gud 2y agoIt’s not everywhere though, FreeBSD for example doesn’t use it.
- 10000truths 2y agoIt doesn't come with bash pre-installed, but installing it is as simple as "pkg install bash", and that is the option that everyone working with FreeBSD will choose when they encounter a shell script that only works with bash. My point is that bash is already so ubiquitous that almost no one is going to care about an extra few megabytes for the bash executable in their OS image.
- justaj 2y agoIf you're installing packages anyway, then why not just write in Python, Go, or any other languages which have relatively less footguns and have more features? I'm sure at least some of those packages are also available on FreeBSD.
- throwaway458864 2y agoNot every shell script has to be that portable. And even then, "POSIX compatible" shells vary in their "POSIXness". Sometimes using arrays is the right thing to do, or having a reliable indicator of the source script location, so you code to Bash 3. Sometimes associative arrays or something else is better, and your platform is known, so you code to Bash 4 or 5. Maybe all your users are Zsh users so you use that. So you can start by writing POSIX compatible scripts, but there's no sense in tying your hands if you don't need to. The Bash manual also covers POSIX semantics, I just remember which is which. You're right that the Dash manual is a good place to check what is mostly POSIX (Dash isn't actually strictly POSIX). I would probably use Shellcheck with the correct shebang to double check what's compatible.
- Danjoe4 2y agoEh, bash is pretty damn portable
- JTbane 2y agoI would RTFM so I actually learn something instead of using """AI""" regurgitation.
- alanbernstein 2y agoI find the manual for bash to be a terrible way to learn things
- red-iron-pine 2y agoman pages are great if you already know 100% what you need to do, and just need a refresher. but if you don't, and the tldr command isn't available, then good freakin luck.
- epiccoleman 2y ago`curl cheat.sh/$command_name` usually works pretty well! (as long as you've got curl, of course)