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.
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.
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?
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?
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.
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.
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".
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.