Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

set -euo pipefail should NEVER be used in a bash script. If you feel tempted to do so, then you are trying to make the shell scripting language be something that it is not.

This is the time for a full scale programming language such as Python or perhaps Groovy on the JVM or Go language. When you need to write robust code, use the tools that were created for writing robust code.

Bash just has too many quirks.

Note that this is related to the most common way that people build a Big Ball of Mud. You have a simple app and you need a couple of features so you add them on. Rinse and repeat. Before too long you have an app that does too much and was never designed/architected to do that much stuff. You are probably ignoring a number of techniques for integrating functionality in large apps such as message queueing, microservices, separate libraries or packages, multiple languages.

Shell scripts suffer the same trajectory towards too much complexity. When you see it happening, and before the task gets too complex, replace the script with an app and apply all the normal software engineering techniques to make it robust.



The good thing about Apache Groovy (on the JVM) is when the big ball of mud starts forming, because its syntax is close enough to Java's, it's easy to quickly split parts off and rewrite it in Java. Only the lambda syntax and some other inconsistencies like the behavior of == are different.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: