You are not logged in.
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 are two Linux ports of this program available:
https://github.com/dimkr/loksh
They compile under Devuan so I have packaged them up and added it to my OBS repository (the oksh package was ported by an OpenBSD developer and so should probably be favoured):
https://software.opensuse.org//download … ckage=oksh
https://software.opensuse.org//download … kage=loksh
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/oksh # or /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
EDIT: added oksh port.
Last edited by Head_on_a_Stick (2020-06-05 16:44:38)
Brianna Ghey — Rest In Power
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.
Brianna Ghey — Rest In Power
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)
Brianna Ghey — Rest In Power
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
Brianna Ghey — Rest In Power
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.
Brianna Ghey — Rest In Power
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)
Brianna Ghey — Rest In Power
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.
Brianna Ghey — Rest In Power
Offline
Version 6.7-1 of the dynamically-linked loksh package is now available.
Upstream has switched from a Makefile to Meson and I have no idea how to make a statically-linked package with that so that will have to wait for me to upskill.
Brianna Ghey — Rest In Power
Offline
how tf did I miss this?
Thanks hoas.
Last edited by siva (2020-05-23 14:35:26)
Offline
how tf did I miss this?.
Because you're barely a shadow here these days. You have been missed!
Online
v6.7.1-1 is now available, upstream has included the lolibc subproject in the release tarball so I don't have to hack it in like I did for v6.7-1. I've also moved libncurses6 to the Recommends list because it is now an optional dependency.
I've decided to drop the loksh-static package, I can't get it to build and it's a potential security risk if I miss an update for the embedded libraries.
I forgot to mention but there are no ASCII packages because Meson builds aren't supported by that release's debhelper version. Sorry.
Brianna Ghey — Rest In Power
Offline
what is the benefit of this loksh over say mksh or ksh in the repos as it stands, updated and maintained i suppose?
-rwxr-xr-x 1 root root 275K May 24 21:30 /bin/mksh*
https://packages.debian.org/buster/mksh
Last edited by HevyDevy (2020-05-24 15:20:13)
Offline
The loksh package is derived from OpenBSD's KornShell implementation and so is audited and maintained by their devs.
It is very slightly "lighter" than mksh and also a tiny bit faster but it lacks support for here strings (here documents still work though). In respect of the original KornShell, that is significantly faster (it is the fastest of all the Bourne shells by some margin) but the ksh93 version in ASCII & beowulf is very old and has quite a few bugs — the new 2020 version in chimera/ceres fixes most of these and is under heavy development.
All three KornShell implementations are actively developed and maintained.
EDIT: loksh is the only one with bash-style PS1 support though, which I like.
Last edited by Head_on_a_Stick (2020-05-24 15:31:01)
Brianna Ghey — Rest In Power
Offline
Yeah i use openbsd on another machine, 6.7 has proved to be really good performance wise on my intel gear.
Would be nice to see debian pick up loksh in testing.
I see alpine linux and some other musl libc based distros have picked this up, i actually dual boot alpine and openbsd on said machine so will have to install loksh on alpine
Last edited by HevyDevy (2020-05-24 16:16:32)
Offline
siva wrote:how tf did I miss this?.
Because you're barely a shadow here these days. You have been missed!
^_^
Statically-linked version here...
I tried following the link and it said the file isn't found
Offline
I've removed the statically-linked version, I can't get it to build under Meson and it's a potential security risk anyway.
The mksh package provides two statically linked versions using musl & klibc, both of which are better than glibc (which has problems with static linking) and Thorsten is a *much* better maintainer than I so use that if you need a KornShell for rescue & recovery purposes.
Brianna Ghey — Rest In Power
Offline
OT for this thread but hey ho...
the new 2020 version in chimera/ceres fixes most of these and is under heavy development.
I've just backported that version of the original KornShell to beowulf:
https://software.opensuse.org//download … ackage=ksh
It's building now, should be ready soon.
Brianna Ghey — Rest In Power
Offline
What are the differences in your backport to the locally available ksh in stable/testing ?
Offline
The AT&T KornShell version in beowulf is ksh93, which is old and buggy. My backport is ksh2020, which is shiny and (mostly) fixed.
Brianna Ghey — Rest In Power
Offline
I've added another port to the OP — it's called oksh and was created by Brian Callahan (also known as ibara), who is an OpenBSD developer.
Brianna Ghey — Rest In Power
Offline
Version 6.7.4 of loksh is building now, it should be available soon:
https://software.opensuse.org//download … kage=loksh
@ibara has oksh v6.7.1 available but it's a pre-release and the only change is for cross-compilation support so I'm not updating the packages. OpenBSD 6.8 should be out soon and I will update oksh to that version as soon as it is available.
Brianna Ghey — Rest In Power
Offline
Version 6.8 of loksh is now available:
https://software.opensuse.org//download … kage=loksh
I'm sure Dr. Callahan will have v6.8 of oksh out soon, I'll bump the thread when that happens.
Brianna Ghey — Rest In Power
Offline
Version 6.8.1 of oksh is now available:
Brianna Ghey — Rest In Power
Offline
The loksh package is derived from OpenBSD's KornShell implementation and so is audited and maintained by their devs.
It is very slightly "lighter" than mksh and also a tiny bit faster but it lacks support for here strings (here documents still work though). In respect of the original KornShell, that is significantly faster (it is the fastest of all the Bourne shells by some margin) but the ksh93 version in ASCII & beowulf is very old and has quite a few bugs — the new 2020 version in chimera/ceres fixes most of these and is under heavy development.
All three KornShell implementations are actively developed and maintained.
EDIT: loksh is the only one with bash-style PS1 support though, which I like.
Any quick and easy reference to the pros/cons of the three? I'm a KSH user at heart and haven't got to installing it and configuring it how i want yet so am open to improvements .
Offline