3 ms·
Great tool that everyone should be using for shell scripts! Then again, I've learnt more than once that you start with "I'm just capturing a few commands in a
by __bjoernd 6y ago
Great tool that everyone should be using for shell scripts!
Then again, I've learnt more than once that you start with "I'm just capturing a few commands in a script" and the next thing you see is a mess of special characters, crude syntax and nasty error handling. Don't be like me...
- cylon13 6y agoI find it helps if you have a hard rewrite rule. I really love the convenience of shell scripts for small scripts, but as soon as I have one that crosses 100 lines I rewrite it in python. The python version is a bit less convenient for spawning processes and piping them together, but it's so much more maintainable that you can scale it up to quite a bit larger without as much worry. 100 lines is a nice size where it doesn't take very long to rewrite, so even though I figure I could get away with a longer shell script without it getting too bad, I'm definitely not going to want to rewrite it once it gets big enough to be a problem.
- atleta 6y agoInvoke [1] can make it a bit more convenient. [1] https://www.pyinvoke.org/ https://www.pyinvoke.org/
- kawsper 6y agoI am you, except my go-to is Ruby.
- qbasic_forever 6y agoAnd then you get to google scale and realize using python for every config, like your entire build system, leads to a huge mess of completely non-deterministic build scripts that do wacky things like make HTTP calls to prod systems, depend on all kinds of global state stores, etc. So you build a new version of python that strips out all of the non-determinism and move your config to that (see starlark: https://docs.bazel.build/versions/master/skylark/language.html https://docs.bazel.build/versions/master/skylark/language.ht... ).
- blabitty 6y agoI know I'm in the minority but I just don't care for python for sysadmin / devops type tasks. It fails in weird ways on file and directory manipulations and I just don't find it's stack traces very informative. A lot of scripts seem to be a bunch of system () calls strung together, how is that better than well written Shell code? What I love python for is scraping web pages and dealing with JSON or xml it rocks for that.