4 ms·
Alternatively, Is there any reason today to not just use a language like Python/Ruby/JS for where shell languages would have been used?
by psetq 8y ago
Alternatively, Is there any reason today to not just use a language like Python/Ruby/JS for where shell languages would have been used?
- reificator 8y agoNumber one reason is availability. Do all of your current and future targets have the right version of Ruby installed? What if you have a mix of python 2.7 and 3.6?
- sethrin 8y agoI'm strongly considering making it a point to do just that: include Ruby in all the images I can, just to not have to use Bash. For one-liners it's fine, but I don't get ten lines into a Bash script before missing scripting-language features. However, if someone were to try to talk me out of what they consider to be an absurd notion, I would be prepared to take their criticism seriously.
- gkya 8y agoI have multiple ~10 line POSIX shell scripts in my dotfiles. I also have a bunch each of Perl and Python ones [1]. I'd rather not rewrite my shell scripts with neither of that languages, or Ruby (which I like and use a bit). When scripting, I find general-purpose languages are better when you have structured data (i.e. some JSON coming in) or you want to use libraries, and shell scripting better when you're wiring up multiple programs to work together, or starting up a program after setting up the environment for it. IIRC, the FreeBSD sh(1) man page was a good entry to writing POSIX compliant, thus quite portable shell scripts. [1] Compare the ones here: https://github.com/cadadr/configuration/tree/master/bin https://github.com/cadadr/configuration/tree/master/bin
- yjftsjthsd-h 8y agoIt really depends on target environment. At work? Sure, every single machine comes out of provisioning with Python 2.7 installed. For something that gets distributed to be used by other people? No way I'd trust anything but POSIX, and that's pushing it some days.
- oblio 8y agoTheir interaction with processes is very awkward compared to shells or even Tcl.
- frou_dh 8y agoUnlike (ba)sh, those languages are not a DSL for manipulating processes and files. (Ba)sh is more accurately framed as an ancient DSL than as a general-purpose language that has now been exposed as subpar.
- peterwwillis 8y agoA shell script is designed with file operators, environment variables, file handle redirection, process control, pipes/ipc, etc as first class primitives. It's just far easier to write a shell script if all you need to do is manipulate some executable programs.
- de_watcher 8y agoShell is like a LISP with less parentheses. And it's inside the text/files/executables environment.