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

I find that Python scripts that deal with calling other programs have even more sharp edges because now you have to deal with stdin, stderr and stdout much more explicitly. Now you need to both know shell scripting AND Python.

Python’s subprocess has communicate(), check_output() and other helpers which takes care of a lot but (a) you need to know what method you should actually call and (b) if you need to do something outside of that, you have to use Popen directly and it’s much more work than just writing a shell script. All doable if you understand pipes and all that but if you don’t, you’ll be just throwing stuff at the wall until something sticks.



1) If possible, don't run shell scripts with Python. Evaluate why you are trying to do that and don't. 2) Python has a bunch of infrastructure compared to shell, you can use it. Shell scripts don't. 3) Apply the same you used for the script to what it calls. CI calls control script for job, script calls tools/libraries for heavy lifting.

Often the shell script just calls a python/Ruby/rust exec anyways...

Shell scripts are for scripting...the shell. Nothing else.


Sure but I already know all this at a level deeper than most people.

Your average person is going to be blindsighted.


Your average person will be blind sighted either way, at least one way they have a much better set of tools to help them out, once they are blind sighted.


Yes, but at least that's all fairly obvious---you might not know how to solve the problem, but at least you know you have a problem that needs solving. Compare that to the hidden pitfalls of eg dealing with whitespace in filenames in shell scripts. Or misspelled variable names that accidentally refer to non-existent variables but get treated as if they are set to be "".




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

Search: