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
-
@atheist I agree for syntax, error handling, variable handling and other things. But bash is better when calling other programs and piping.
-
@happygimp0 I laughed very hard reading that statement...
Note that the bash options are far better suited for what you have in mind.
https://tldp.org/LDP/abs/...
set -o xtrace
specifically. -
@IntrusionCM Disagree, it pollutes the output. The script should only print something when there was an error.
-
atheist99813y@happygimp0 ehhhh... I'd actually disagree with that.
Have you ever had to work out how to escape some bash string stupidity?
Python, each token is a string. you pass a list of tokens to subprocess.run. I've actually used Python's shlex.join method to work out *how* to shell escape something. -
@happygimp0
Don't use traps for "exception" handling.
It will bite you. Do it properly and it will save you a lot of migraine.
There are tons of caveats, be it functions, dependency on options like errexit and other stuff.
You think you have an easy way, but you just opened the box of pandora.
:) -
Bash (and make) have its good cases - very simple scripts that doesn’t require an entire language runtime to work.
In terms of python, use plumbum and you’ll be fine; the experience is really smooth.
Related Rants
Why did it take years before someone told me to add this to your bash script to see the line on which a command failed?
errorOnLine() { echo "Line $1 had an error" ; exit 1 ; }
trap 'errorOnLine $LINENO' ERR
random
bash
line
error