help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sub-process changing value available to parent process?


From: Greg Wooledge
Subject: Re: sub-process changing value available to parent process?
Date: Tue, 28 Apr 2020 07:37:53 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Tue, Apr 28, 2020 at 06:41:45AM +0200, Marco Ippolito wrote:
> > > > set -euo pipefail
> > > As soon as I saw this, I decided to delete the entire thread.  This
> > > is not salvageable.  This is a sign of grave incompetence and/or
> > > ignorance.  Combined with "I know the answer is eval but I want a
> > > different answer", it points to intransigent stubbornness.
> > 
> > Sorry I probably miss some references here.
> 
> A reference was indeed missing.
> 
> Among others, many of which from Greg himself, I could find:
> https://mywiki.wooledge.org/BashFAQ/105
> 
> Explore from that site for more.
> 
> Greg may want to expand with additional links.

Sadly, we haven't bothered to write a whole page for "set -euo pipefail"
yet, although it probably deserves one.

To really understand the issues, first you have to look at the historical
problems surrounding set -e and set -u, both of which are well documented.

https://mywiki.wooledge.org/BashFAQ/105
https://mywiki.wooledge.org/BashFAQ/112

So you've got super bad idea #1, and pretty bad idea #2, both of which
are well known to create more problems than they solve.

Now you use BOTH of them TOGETHER, because bad x bad = super bad,
and super bad must be good!  Or something.

But wait, it turns out super bad isn't terrible enough.  So, we decide
to EXTEND set -e to make it even worse!  Normally, set -e only applies
to the last command in each pipeline.  But what if we could make it apply
to EVERY command in the pipeline instead?  How awful^H^H^Hesome would
that be?!

Chet gave us set -o pipefail which lets us do exactly that!  Hooray!
Now our shell scripts can mysteriously die in the middle of the night
for ANY reason at all, instead of just some of the reasons!

Some of the people out there decided that these three things combined
together are so incredibly bad that they should be promoted as a
STANDARD!  They even came up with a CATCHY NAME for it!

http://redsymbol.net/articles/unofficial-bash-strict-mode/

Unofficial Bash Strict Mode: When you want to be absolutely certain
that your script's chances of dying for no discernable reason have
been fully maximized!  Accept no substitutes!

This shit spread like a virus.  Everyone lost their freaking MINDS when
they learned about this.  They decided they just HAD to get them some of
this!  Why write scripts that would actually run, when you could play
Russian roulette with every script?

https://gist.github.com/robin-a-meade/58d60124b88b60816e8349d1e3938615
https://github.com/carpentries-incubator/shell-extras/issues/30
https://disconnected.systems/blog/another-bash-strict-mode/
https://lukescott.co/2019/06/10/bash-unofficial-strict-mode/
https://www.reddit.com/r/programming/comments/25y6yt/use_the_unofficial_bash_strict_mode_unless_you/
https://news.ycombinator.com/item?id=8054440

So, every newbie who has been exposed to this memetic virus has had
their brain permanently damaged.  You see this thing cargo-culted
EVERYWHERE.

As soon as I see it in someone's question, I know to turn away immediately
before I get even more angry.

At this point, I don't know how to solve the problem that people always
latch on to what they perceive as a Quick Miracle Cure.  We've been
trying for years to educate people about how bad set -e is, and then
THIS happens, and in a month, all of our work is swept away by this
tidal wave of incompetence.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]