5 ms·
> It's a very sensible system scripting language, alongside Python, Perl, etc. I’ve always assumed that the main benefit of bash scripts is that they’re portab
by hnarn 5y ago
> It's a very sensible system scripting language, alongside Python, Perl, etc.
I’ve always assumed that the main benefit of bash scripts is that they’re portable and universal. If you’re willing to compromise that, why not just go with python? I don’t really understand which gap zsh fills here.
- nerdponx 5y agoI didn't mean to imply that Zsh was somehow more portable than Python. And I agree with the sibling commenter that Python is probably more portable than Bash. I use Zsh for many of my personal scripts, but at work I would never even try to get it into one of our production containers.
- echelon 5y agoFurthermore, interactive zsh totally breaks vim-like input mode. If you choose vim keybindings for navigation, it utterly breaks reverse-r search and the hacks you have to use to fix it do not make it an equivalent experience. It's like the zsh folks said, "fuck those vim guys". If I didn't have to use a Mac at work and our tooling didn't behave oddly in bash, I wouldn't use it. Bash is much more comfortable.
- soraminazuki 5y agoWhat are you talking about? Using reverse-r search in vi mode requires a single line config, no hacks involved. bindkey -v '^R' history-incremental-search-backward I'd say that if you want vim-like bindings, zsh is a much better option. It provides Vim's text objects, surround.vim bindings, and visual selection which bash does not. Also unlike bash, you're free to create your own keybinding if none of the builtin ones suffice. I did exactly that to get an increment/decrement operator that behaves exactly like Vim's ^a/^x. It's like the zsh folks said, "I like those vim guys".
- accelbred 5y agoAs a vim user, zsh's vim mode is far better. You do need a few lines of config for stuff like allowing deleting back past the insert position. However, I have never found it lacking, unlike bash which sometimes lacks some motion I try to use.
- acdha 5y agoI've generally ported _to_ Python to see improved portability: the problem with bash is that it's not just what versions of bash you have installed (if you support RHEL, MacOS, etc. that can limit you significantly) but also all of the utilities which you call so you probably end up needing to wrap things like readlink once you need to run on more than one of GNU, BSD, busybox, etc. Obviously you can get a fair amount done with pure POSIX but for me it's almost inevitably hit the point where you rewrite it in something else and realize that it's like 30% fewer lines of easier to understand code.
- hnarn 5y agoFine, but this does nothing to address the value of zsh which is what I was asking about.
- professoretc 5y ago> why not just go with python? I can't speak for anyone else, but for me, it's because Python is cumbersome for doing the sorts of things that are easy in a shell. You want to capture the output of a command, parse it as a tab-separated table, extract the 3rd and 4th columns, and then use them to create new users with the values supplying usernames and passwords. Can you do that easily in Python?
- int_19h 5y agohttps://amoffat.github.io/sh/ https://amoffat.github.io/sh/
- hnarn 5y ago> Can you do that easily in Python? I'm not arguing for Python over bash, I'm asking about the value of zsh as opposed to bash or python. So why couldn't one do what you describe in bash? The answer probably is you very well could. So why use zsh for scripting?
- LordDragonfang 5y agoFor all its syntactic sugar, dealing with files in python (which comprises probably 90% of what I open a shell for) still requires a fair amount of boilerplate. Which is good for a general scripting language, but makes it poor for the the kind of tasks I expect of a shell.