3 ms·
I'm not convinced. >when should i use shell? >in short; when the problem you're solving is small, well defined, and unlikely to change, consider shell. If yo
by _dain_ 4y ago
I'm not convinced.
>when should i use shell?
>in short; when the problem you're solving is small, well defined, and unlikely to change, consider shell.
If you have to caveat it this much, it's a pretty weak statement. Any language works when the problem is small, well defined, and unlikely to change!
Strict POSIX compatibility is something of a chimera. You don't just need to read the POSIX shell spec, because you're not just programming in POSIX shell, you have to use the coreutils as well to get anything done. Do you remember which flags on grep are POSIX-only, and which are extensions provided by the GNU version? And then the same for sed, ls, and the rest of the UNIX zoo? There's an order of magnitude more shit you have to remember and worry about.
Needing strict POSIX compatibility is an increasingly niche use-case. I find it baffling that, on the one hand, we have these modern software isolation and distribution systems like containers and Nix and so on, technologies that are meant to let us run anything anywhere reliably, and then we forget we have these marvels and wear the POSIX hair-shirt anyway. Why can't you just include a better language in the container? A container is supposed to contain things! Stop hitting yourself in the face repeatedly!
Finally if you somehow really do need to live in the POSIX cave, you don't need to use shell. POSIX also specifies a much saner language: awk.
- blueflow 4y ago> Do you remember which flags on grep are POSIX-only, and which are extensions provided by the GNU version? Use the posix man pages as reference. `man 1p grep` and you only see the portable options. Its only one step away from using the regular manpages.
- abathur 4y agotil :)
- Karellen 4y agoWorth noting that `man-pages-posix` is not under any kind of Free/Open Source/CC-style license, so may not be available by default for your OS. e.g. in Debian you have to enable the `non-free` section to make them apt-installable.
- justaj 4y agoUnfortunately doesn't seem to be present on all systems: No manual entry for grep in section 1p See 'man 7 undocumented' for help when manual pages are not available. Ubuntu 18.04 here
- lmz 4y agoInstall the `manpages-posix` package: https://packages.ubuntu.com/bionic/all/manpages-posix/filelist https://packages.ubuntu.com/bionic/all/manpages-posix/fileli...