4 ms·
I probably have a similar history but I've come to the belief that you should not use Bash if you're doing anything fancy or long (>10 lines). Just use Perl, P
by emmelaich 9y ago
I probably have a similar history but I've come to the belief that you should not use Bash if you're doing anything fancy or long (>10 lines).
Just use Perl, Python or Ruby. One or all of them is installed on every machine you are likely to use.
- davedx 9y agoYes, but which one, and which version? This is especially painful with Python ;)
- h1d 9y agoWhat's painful about Python but not so for others? Writing anything complicated in bash/zsh is painful enough I wouldn't even think about it.
- CJefferson 9y agoI currently find some users have python2, some have python3, some both. It's fine in a controlled environment, or if your users are Devs, but a pain with normal users who I just want to send a script to.
- Groxx 9y ago2 vs 3 is not a small change. and tools for helping you do things (like a 3+2 compatibility lib) get installed with pip... which is horrifyingly fragile. `pip install your-lib` -> you have no idea if you have the dependencies you require, because pip doesn't behave rationally. it often Just Works™, but when it doesn't there's no help and a massive minefield of potential problems.
- vinceguidry 9y agoUse Ruby. It doesn't change much from version to version, thank God. I curse python every time I have to install a package. Nothing Just Works. If you install just one gem, bundler, you can get dependency management in a one-file script. Checkout Bundler Inline: https://github.com/bundler/bundler/blob/master/lib/bundler/inline.rb https://github.com/bundler/bundler/blob/master/lib/bundler/i...
- mncolinlee 9y agoKotlinScript is yet another option that handles that worry nicely. https://github.com/holgerbrandl/kscript https://github.com/holgerbrandl/kscript
- yAnonymous 9y agoIs there an easy way to run shell commands in Python, like backticks in PERL, Ruby or even PHP? I'd really like to use Python more often, but most of the time it only complicates things with those verbose syscalls.
- neillyons 9y agoUnfortunately not. I have used Ruby a little bit and that is really nice feature.
- monort 9y agoCheck out python sh: https://github.com/amoffat/sh https://github.com/amoffat/sh
- yAnonymous 9y ago>sh.ls("-l", "/tmp", color="never") Nope. I really need to be able to test commands on the terminal and then copy/paste them without any modifications. I won't even try to get used to that stupid syntax.
- passwd 9y agoIPython. Seems to work for simple stuff like `ls blah`, but I'm not aware how far this stretches, and is probably not super safe to use. EDIT: Seems I've only tried too basic things - it works thanks to %automagic, and seemingly %man is a thing. Other option is to use %%sh or %%bash, but that's a bit verbose.
- rcxdude 9y agopart of the complication is due to actually having the proper data seperation that you need to jump through hoops to get in bash. If you go with backtick style calls you lose a lot of that.
- sxv 9y agoos.system() (https://unix.stackexchange.com/a/238185 https://unix.stackexchange.com/a/238185)
- freedomben 9y agoExcept for perl, python and ruby are rarely on container images and AMIs I interact with unless they are needed for the application itself to minimize attack surfaces and vectors. Perl is installed sometimes due to dependent packages that themselves depend on perl, but that's becoming much less true as time goes on. With Docker it's also very easy to keep your image super minimal. Most of the time we don't even have bash installed (just sh).