4 ms·
I love python, but python is not a shell, and it makes an absolutely awful shell replacement. Python is further from a good shell than bash is from being a dece
by dahart 11y ago
I love python, but python is not a shell, and it makes an absolutely awful shell replacement. Python is further from a good shell than bash is from being a decent programming language. Some scripts are good, I do use python for some kinds of shell scripts, but most of what I need bash for, python is not a good replacement at all.
- moondev 11y agoBut the goal of this is not shell replacement correct? It is a way to write scripts for both platforms. Python has great cross-platform support in that regard: http://hplgit.github.io/edu/ostasks/._ostasks002.html http://hplgit.github.io/edu/ostasks/._ostasks002.html
- dahart 11y agoYes, you're right. Batsh isn't trying to be a shell replacement, but it is targeting the two shells that you're nearly guaranteed to find one of on any given computer. I dunno if @zwieback was saying Batsh should target python, or if people should use python instead of Batsh, or something else, but neither of those first two suggestions makes a lot of sense to me. Python's decent cross platform support doesn't really make it better for shell scripts, and while I use it for some shell scripts, I don't ever default to python. My comment was reacting to the "wouldn't you just", as though python is a natural default choice. In my experience, it's not a good default choice. It's harder to debug python shell scripts, because you typically can't run individual lines, you typically can't cut and paste parts of it, you can't ever run system commands directly without wrapping it in a python module call, output might not display automatically, and you often have to install something that isn't already on the machine.
- TillE 11y agoPerl is probably still the best in its class of being a decent language while allowing close interaction with shell commands. If I really needed to write a sophisticated shell script (try to avoid that), I'd probably go for Perl.
- xyience 11y agoI'm mostly in agreement about Perl's status, but I'd rather take the small hit in verbosity for the niceness of the rest of Python rather than having to deal with Perl... Yeah it kind of sucks not having the backtick operator, but at least it's not too much of a hassle to do something like: from subprocess import check_output as sh files = sh(['ls']) print files This has its limits but covers a lot of basic use-cases for the backtick. I think some people first see an alternate way of doing this in Python that's a lot more hairy, even if more flexible, but it doesn't have to be that way...