4 ms·
From the article: consider this sentence: "arrays do not exist in posix shell" ... "NOOO!" you shout, because you like data structures a LOT "now
by jamal-kumar 4y ago
From the article:
consider this sentence:
"arrays do not exist in posix shell"
...
"NOOO!" you shout, because you like data structures a LOT
"now THAT'S a good reason to use bash! bash supports arrays!"
absolutely not!
i believe that you should use shell if your problem is:
- small and scoped (~200 lines of shell or less)
- unlikely to increase in size and scope as time goes on
- not very complex
if you find yourself desiring arrays, good error handling,
static typing, structs, etc, then your problem should
be solved using a different language, not shell.
I tend to agree with this heuristic.
It's also why you see people bothering to use perl 5 at all in this day and age. It just happens to be preinstalled on a decent majority of *nix systems.
- djbusby 4y agoPerl and Python are part of LSB https://refspecs.linuxfoundation.org/lsb.shtml https://refspecs.linuxfoundation.org/lsb.shtml
- hedora 4y agoYeah, but perl 5 hasn’t broken compatibility (as far as I’ve noticed) since 2000 or so. Python breaks compatibility every week, in practice. Does LSB include some sort of magical frozen in time version of python 2 or something?
- gabrielhidasy 4y agoIn my 12 years of python I was hit with compatibility problems once, in a school project where someone started in python 2 and we changed for python 3. What libraries break that often so I can stay away?
- hedora 4y agoscipy / numpy / etc broke multiple times for me. I’m usually dealing with other people’s python, so I don’t remember which ones broke. Usually stuff around 3rd party services, async I/O or parsing.
- mananaysiempre 4y agoSo is the RPM format. I like LSB particularly as a reference for obscure ABI details, but I don’t think anybody actually builds either systems or applications to it.
- temac 4y agoLSB support has been mostly dropped by some distros (e.g. Debian dropped support in 2015)
- jamal-kumar 4y agoI'm more concerned about whether or not people on BSD or OSX can use my scripts to be honest
- mananaysiempre 4y agoA young traveller came to visit Emperor Sh, and found him sitting in his sparsely furnished temple. “Emperor Sh,” he said, “I am told you are the greatest scholar of shell that the world has known.” Emperor Sh made no reply. The traveller continued. “I have come to ask your advice. I am thinking of developing a character-based graphing tool. It will interactively change the plot based on key presses. Which shell commands should I use?” “Don’t do it in shell,” said Emperor Sh, curtly. The young traveller was confused. He tried again. “Well… I am also working on a database audit script. It needs to verify that certain characters do not appear in any fields in several tables. What should—” “Don’t do it in shell,” interrupted Emperor Sh. The traveller began to despair. “I have journeyed one thousand miles, tried thirteen distributions of my operating system, and waded through hundreds of badly-written manual pages,” he cried, “and now I have finally come to Emperor Sh, the greatest shell programmer in the world, and I am told to use no shell at all! Perhaps I should do what my Python user friends told me to do, and just pipe together some scripts in venv environments!” “Good idea,” said Emperor Sh. “Do it in shell.” Enlightenment crushed down on the young traveller and he bowed to the Emperor, sobbing with reverent joy. https://sanctum.geek.nz/etc/emperor-sh-and-the-traveller.txt https://sanctum.geek.nz/etc/emperor-sh-and-the-traveller.txt
- gmt4 4y agoThanks for sharing that one!
- IshKebab 4y agoThe "unlikely to increase in size or scope" is the big one. It basically eliminates almost all uses of shell scripts (as it should). I would add a 4th condition: you aren't going to share the script with anyone else (including CI) - it's going to stay strictly on your computer and nobody else will ever read it.