News for hackers. Stuff that matters.
Re:Minimal safe Bash script template by jancsika on Tuesday December 15, 2020 @11:04AM (#25431479)
> Just like JavaScript, it won’t go away easily.

No, not "just like." Whatever you think of JS the tweet above this quote doesn't apply-- I don't constantly have to look up how a function callback works, or how to do math.

To be "just like" shell scripting, you'd have to get JS devs to start regularly using `eval` in lots of unnecessary places, plus using arbitrary, inconsistent use of single-letter aliases for some of the core methods

I mean...

> set -Eeuo pipefail

Upper and lowercase! And the flag meanings aren't even explained in this article!

Edit: To be honest, this reflects my own mental model for shell commands: commandName -garblegooklegarblegookle myArg1 myArg2 etc..

Re:Minimal safe Bash script template by rhencke on Tuesday December 15, 2020 @11:10AM (#25431539)

    $ help set
    
    ...
          -e  Exit immediately if a command exits with a non-zero status.
          -E  If set, the ERR trap is inherited by shell functions.
          -u  Treat unset variables as an error when substituting.
          -o option-name
              Set the variable corresponding to option-name:
                           pipefail     the return value of a pipeline is the status of
                           the last command to exit with a non-zero status,
                           or zero if no command exited with a non-zero status
Re:Minimal safe Bash script template by mradzikowski on Tuesday December 15, 2020 @11:11AM (#25431565)
Hey, the flag meanings are explained in the article I linked in the post: > For details on what options exactly set -Eeuo pipefail changes and how they will protect you, I refer you to the article I have in my bookmarks for a few years now.

Link: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_p...

About "just like JavaScript" - it was sarcasm ;-) I write in TypeScript daily and still make fun of JS. But I agree, Bash is worse!