You are not logged in.
Pages: 1
Although bash is a fine shell with many useful features, it does have it's problems:
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 is a Linux port of this program available:
https://github.com/dimkr/loksh
It compiles under Devuan so I have packaged it up and added it to my OBS repository:
https://software.opensuse.org//download … kage=loksh
Statically-linked version here:
https://software.opensuse.org//download … ksh-static
The repositories are technically for Debian but they should be compatible with Devuan and they only hold the loksh packages, there are absolutely no systemd dependencies at all.
The package currently conflicts with ksh93 because the binaries share the same name but I am researching how to change the name of the installed binary so I can remove the conflict (any hints welcomed), I will update the package when I figure it out. Fixed!
To change the default interactive shell run
chsh -s /bin/loksh
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:
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):
set -o emacs
[1] Output of ps_mem showing memory usage:
580.0 KiB + 96.5 KiB = 676.5 KiB ksh
2.4 MiB + 216.5 KiB = 2.6 MiB bash
Size of binaries:
-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:
$ time for i in $(seq 1 1000000);do [ 1 = 1 ];done
0m01.96s real 0m01.90s user 0m00.09s system
Bash:
$ 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:
$ time for i in {1..1000000};do [ 1 = 1 ];done
real 0m3.944s
user 0m3.876s
sys 0m0.064s
Last edited by Head_on_a_Stick (2019-04-13 23:03:40)
Fabricando fit faber
Offline
Having a conflicts stanza in the control file, which you should have if you want to distribute this (I haven't checked) is not going to work as a long term solution. You will be better served with some renaming (prefixing) of binaries and perhaps an install target in /usr/local - end user can then just set up aliases as necessary and there's much less danger of your 3rd party package clobbering anything from official repos.
Offline
^ Thank you very much cynwulf, that is excellent advice.
And I've just realised that my package breaks the ksh alternative as well because it overwrites it...
I will try to patch the Makefile, I think that's the way forward here.
Fabricando fit faber
Offline
Quilt rocks!
Patched the Makefile to rename the binary to /bin/loksh and added loksh to the ksh alternative system.
The package no longer conflicts with ksh93 and can be safely co-installed
New version is 6.4-1.1:
https://software.opensuse.org//download … kage=loksh
To set it as the default shell use either
chsh -s /bin/loksh
Or use /bin/ksh instead and also run
update-alternatives --set ksh /bin/loksh
to set loksh as the /bin/ksh alternative.
Last edited by Head_on_a_Stick (2019-04-11 15:21:44)
Fabricando fit faber
Offline
Added a statically-linked version (useful for rescue situations in which /usr is not available) and also included all the hardening flags (-fstackprotector-strong etc), version bumped to 6.4-2
Fabricando fit faber
Offline
Version 6.4-3 is out.
I made a mistake (again) with the binary location that broke the alternatives and I didn't notice 'cos my systems are /usr-merged.
It's fixed now.
OpenBSD 6.5 is due out very soon so I think we'll see v6.5 of loksh shortly afterwards.
Fabricando fit faber
Offline
Version 6.5-1 is building now
It should be available soon.
EDIT: now in the repository.
Last edited by Head_on_a_Stick (2019-04-24 20:56:23)
Fabricando fit faber
Offline
Version 6.6-1 is now available.
I've tidied up the packaging a bit so Lintian now only complains about the embedded ncurses library in the statically-linked version.
Fabricando fit faber
Offline
Pages: 1