for i in `seq 1 10` ; do
echo i $i
done
for i in range(1,10):
print("i %i\n")
You might find problems with the shell code, and I'll find problems with the Python. But both will print 1 to 10.The biggest reason why I don't use it all of the time is that calling / piping commands takes a lot more typing, so it's easier to use bash for very simple shell scripts. And while there are libraries that simplify shell scripting, that adds external dependencies to your scripts.
> for i in range(1,10): > print("i %i\n")
This outputs "i %i\n\n" 9 times.
damn, ya got me there. to be fair, I was drunk when I wrote that xD
Most of the things on this list couldn't happen in Python:
https://www-uxsup.csx.cam.ac.uk/misc/horror.txt
Your exanples were bugs which were not caught during development because "testing is hard and expensive" and "if it compiles, ship it".
If you want to do more advanced things there is always the right tool for the job although with an increased attack surface.
Remember that time bumblebee accidentally deleted everyone's /usr? Or that time steam deleted everyone's homedir? Both because of the easiest to avoid bash footguns - spaces and empty variables.
My hard and fast rule that I've never regretted is - if you use a bash if statement, consider python. If you're going to do a for loop, you must instead use python.
Typically as a side effect once the programmer is in python at my prompting, they find having such easy access to libraries suddenly lets them make the whole script more robust - proper argparsing is an immediate one that comes to mind.
Frequently the reticence I see from people, especially juniors, is that they're worried about people thinking "haha they have to pull an entire python into their image just to run this script" or "wow they're so newbie/young that they can't even write some shell". I reassure them: don't worry, there's a reason we used Perl even back then too.