Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
b2plane63891yWish i could learn bash. Then again i havent bumped into literally any need of actually needing to code a complex bash program for literally anything. It was always something very simple
-
Some tips
set -o errexit
might be more verbose, but definitely cleaner to read.
set -o pipefail is a good idea, too.
Best is usually to still check explicitly cmds return code, cause you don't end up with a script where all error handling is implicit. -
God damn it. I was reading through comments and thinking "wtf they're on about?!? How's ´sed -e´ related to bash...?"
i need to wake up better -
cho-uc18841yI just recently delve into bash script again.
My senior told me to use specific error code :
- case A : exit 10
- case B : exit 20
and so on.
So I can't use globally set -e in this case -
-
@cho-uc
Not true.
set -o errexit just takes care of all "unchecked" conditions.
if ! thisIsABadIdea; then
exit 20
fi
Still works.
(given that thisIsABadIdea is a function with a return code != 0 or a program with exit code != 0).
Conditionals are exempt from errexit.
Thus errexit is an implicit fallback, which is why I would recommend doing explicit checks and using errexit as a failsafe. -
@Demolishun but at least you know you are and are not an arrogant prick about it. The Socratic way has always proven to be the best path forward.
Don't worry, every time it will be better and you will forget less often.
Related Rants
huge confession bear...
i just learned what set -e does in bash
i've been using logical and (&&) this whole time
😂😂😂😂😂😂😂😂
i have become what i hate 🤡🤡🤡
rant
clownworld
bash
noob
lol
fail