News for hackers. Stuff that matters.
Re:Write Posix Shell by jamal-kumar on Saturday March 11, 2023 @10:50AM (#35109287)
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.

Re:Write Posix Shell by mananaysiempre on Saturday March 11, 2023 @11:24AM (#35109723)

  A 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
Re:Write Posix Shell by gmt4 on Sunday March 12, 2023 @03:16AM (#35117621)
Thanks for sharing that one!
Re:Write Posix Shell by djbusby on Saturday March 11, 2023 @11:19AM (#35109663)
Perl and Python are part of LSB

https://refspecs.linuxfoundation.org/lsb.shtml

Re:Write Posix Shell by hedora on Saturday March 11, 2023 @11:26AM (#35109738)
Yeah, 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?
Re:Write Posix Shell by gabrielhidasy on Sunday March 12, 2023 @08:41AM (#35119406)
In 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?
Re:Write Posix Shell by hedora on Sunday March 12, 2023 @01:15PM (#35122906)
scipy / 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.

Re:Write Posix Shell by mananaysiempre on Saturday March 11, 2023 @11:58AM (#35110177)
So 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.
Re:Write Posix Shell by temac on Saturday March 11, 2023 @12:05PM (#35110254)
LSB support has been mostly dropped by some distros (e.g. Debian dropped support in 2015)
Re:Write Posix Shell by jamal-kumar on Sunday March 12, 2023 @11:56AM (#35121653)
I'm more concerned about whether or not people on BSD or OSX can use my scripts to be honest
Re:Write Posix Shell by IshKebab on Sunday March 12, 2023 @01:20PM (#35122978)
The "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.