3 ms·
Ask HN: Why don't more people use the Korn Shell (/bin/ksh)?
It's installed by default on macOS, Solaris and easily installed on Linux. It offers a superior programming features[1] to /bin/sh, much faster than /bin/bash, and you can easily match bash's interactivity with a simple 'set -o emacs' to get redline keybindings.
Why is it generally ignored in the shell discussions?
[1] http://www.kornshell.com/info
- feelin_googley 9y agoIMO, there are two uses of a shell: interactive and non-interactive. The later we might refer to as "scripting". For scripts to be portable, the wisest choice is /bin/sh. For interactive use, it is a matter of preference. FreeBSD used to default to tcsh. OpenBSD used to default to ksh. Personally I prefer /bin/sh as both interactive and non-interactive. This way all my scripts, no matter how small, are portable. And it has enabled me to "master" /bin/sh as a language. I cannot even begin to describe all the advantages I get from that. I'm a shell junkie. But I understand your thought. ksh is superior in many ways. Certainly a more sensible shell than bash, IMHO. And though they may not be popular, csh and tcsh have some useful features not found in /bin/sh or ksh. Most shell discussions on HN draw commnents from people whose primary programming languages are Python or other large scripting languages that more or less make shell programming obsolete. The only time they use the shell is when they have to, not to accomplish "real work", and certainly not for fun. Thus the shells mentioned are usually ones geared toward interactive use. /bin/sh builds my kernels and userlands. I use it every day for just about everything, mainly through libraries of small scripts I continually write and rewrite. I do not even have Python or any other large scripting language installed.
- le-mark 9y agoThe worst in my opinion is working with someone who whips up cool shell scripts/utilities, invariably used in production, and uses a "non standard" shell. Usually checked into source control too. It's just a PITA for everyone else. Same goes for "non standard" command line utilities. If you're writing stuff for your own use fine, but anything shared should be bin/sh, imo.
- Crontab 9y agoI really like your post. And speaking of csh, I recently gave it a try on NetBSD after reading "An Introduction To The C Shell" by Bill Joy. I do kind of like it but I gave up as I just couldn't deal with using Esc for file completion instead of Tab. That's how I ended up giving Tcsh a try.
- deleted 9y ago[deleted]
- akulbe 9y agoI thought /bin/sh didn't even exist everywhere anymore, and that it was merely a symlink to $NEWER_SHELL? Is that not the case?
- Crontab 9y agoI have come to the conclusion that I want a shell that is developed independently of any operating system - so that I can have consistency no matter which Unix-like OS I happen to have installed. I've recently tried Bash, Tcsh, Zsh, and Fish. I ended up going with Tcsh, which Zsh being a close second, but honestly my choice was complete bullshit as it is based in nothing but preference. As for Ksh, I particularly like OpenBSD's version, which is based on pdksh. Sadly, OpenBSD doesn't maintain a portable version like they do with some of their other products (OpenSSH, OpenSMTP, etc).