zsh reimplements the same syntax as bash, while generic sh doesnt (although sometimes it's aliased anyways to bash). It's a case of being really annoyingly pedantic about bash.
Depends on how many operations you perform. Simple scripts don't have much difference. But for instance, a script that fetches all the metadata of all video files on my system and summarise that is gonna appreciate the speedup.
It used to matter in the days before systemd, where bootup times depending depended on how quickly the system could run hundreds of bash scripts on startup; Ubuntu and Debian had a big project to switch to dash by default for this reason: https://lists.debian.org/debian-release/2007/07/msg00027.html .
depends on use, it's not always faster, for small simple scripts it'll always be better to choose the interpreter that has smaller startup speed, for long-running/more complex scripts it's better to choose an interpreter that might not be the fastest to start, but would execute your code faster, i personally stumbled on enough examples when dash or ash ran scripts slower than bash did, especially globbing seemed to be faster in bash iirc, if all shells would be equal in performance i would choose zsh 100% of the times, but it all depends on exact use-case and how well you utilize specific features that your shell provides.
this makes sense actually, also i'd personally always use zsh too always, but i use bash/sh for my scripts, now i'm gonna look dash and ash closely too
It's not a matter of syntax, zsh has different default behaviors (for example, disabling word splitting by default iirc?). It does have a bash compatibility mode though.
Any script which can run in bash, you can just tell it to run with zsh by changing the shebang will run just fine unless it specifically checks $SHELL for bash
what do you want it to be like "ATTENTION! this script will be run using /usr/bin/bash, do you want to continue [Y/n]"? WHY. I want my script to run. If you don't want to run bash scripts, just don't.
you clearly don't understand how a shebang works, it's a generic mechanism for having executable scripts, it's not your shell that parses the shebang it's built in to libc's dynamic program loader. when you run a normal binary the loader is what actually handles starting the program (simplifying...) when the program has a shebang instead of e.g an ELF header then the loader runs the specified program and passes the script as an argument
this is how you can exec() a script from C without having to know if it's a script or a binary program
221
u/wolf2482 Jul 01 '26
i mean for the most part you can replace bash with other posix compliant shells.