bash(1) wrote:BUGS
It's too big and too slow.
OpenBSD uses their own KornShell implementation (derived from the old public domain KornShell, pdksh) as the default shell, the codebase is much smaller than that of bash and benefits from the audits performed regularly by the developers. It uses less memory than bash and is also faster[1] but doesn't support here strings or numerical brace expansion; here documents & standard brace expansion work fine though.
There are two Linux ports of this program available:
https://github.com/ibara/oksh
https://github.com/dimkr/loksh
They both compile under Debian so I have packaged them up and added them to my OBS repository (the oksh package was ported by an OpenBSD developer and so should probably be favoured):
https://software.opensuse.org//download.html?project=home%3AHead_on_a_Stick%3Aoksh&package=oksh
https://software.opensuse.org//download.html?project=home%3AHead_on_a_Stick%3Aoksh&package=loksh
To change the default interactive shell either run
- Code: Select all
chsh -s /bin/oksh # or /bin/loksh
Or set loksh as the ksh alternative and use that instead:
- Code: Select all
# update-alternatives --set ksh /bin/oksh
chsh -s /bin/ksh
The configuration file is set by $ENV so add this to ~/.profile and/or ~/.xsessionrc to make it read ~/.kshrc every time a shell is opened:
- Code: Select all
export ENV="${HOME}/.kshrc"
Note that the command line editing mode is determined by $VISUAL (or $EDITOR if $VISUAL is unset) so if vim is preferred then add this line to ~/.kshrc to restore the usual behaviour (ie, up arrow to recall the history, etc):
- Code: Select all
set -o emacs
[1] Output of ps_mem showing memory usage:
- Code: Select all
580.0 KiB + 96.5 KiB = 676.5 KiB ksh
2.4 MiB + 216.5 KiB = 2.6 MiB bash
Size of binaries:
- Code: Select all
-rwxr-xr-x 1 root root 1.2M Jan 24 10:01 /bin/bash
-rwxr-xr-x 1 root root 264K Apr 9 19:13 /bin/ksh
Rough benchmark for loksh:
- Code: Select all
$ time for i in $(seq 1 1000000);do [ 1 = 1 ];done
0m01.96s real 0m01.90s user 0m00.09s system
Bash:
- Code: Select all
$ time for i in $(seq 1 1000000);do [ 1 = 1 ];done
real 0m3.633s
user 0m3.586s
sys 0m0.061s
Bash with numerical brace expansion:
- Code: Select all
$ time for i in {1..1000000};do [ 1 = 1 ];done
real 0m3.944s
user 0m3.876s
sys 0m0.064s