[Aboriginal] Replacing bash with mksh

Rob Landley rob at landley.net
Sat Jun 8 00:00:49 PDT 2013

On 06/04/2013 09:29:47 PM, idunham at lavabit.com wrote:
> > Ideally I want to get toysh implemented ASAP, and might take some  
> code
> > from the public domain version of mksh to help that. In practice,
> > neither of my last two day jobs has been particularly amenable to
> > having as much free time to program as I'd like, and scheduled stuff
> > likekeeping up with kernel releases (3 targets currently broken in
> > 3.10-rc4) take priority. Plus I should really finish the musl
> > switchover...
> > Rob
> That would be OpenBSD pdksh, for which I'd strongly recomment using  
> one
> of these two Linux ports:
> https://github.com/bobertlo/openbsd-pdksh
> http://slackbuilds.org/repository/14.0/system/ksh-openbsd/
> IIRC, I heard that the latter includes fixes for a number of things  
> that
> "are subtly broken in OpenBSD".

I wasn't planning to take large chunks of code verbatim, I just tend  
not to actually read GPL code before writing a new non-gpl thing. I  
read man pages and standards, and run things under strace.

For public domain stuff, I'm happy to have the PD version open in one  
window while I write another one in a second window, and use it as a  
template. But we've got our own library of reusable code that nothing  
else has, and you've seen how much

> I forget exactly how to go about applying the patches from the latter
> source, but it didn't take that long.
> The libbsd dependency is for one or two functions that are in musl.
> That said, I'll warn you: there are well over 20 C files to go  
> through.
> And there are a few builtins that we have, like mknod.

I noticed this. :)

I'm not opening the shell can of worms until I get the current set of  
loose ends tied off a bit more first. I got "stat" out of pending, I'm  
working to get ifconfig out of pending but the limiting factor at the  
moment is I don't understand what command lines it's parsing and  
there's no ifconfig.test. (set_sockaddr() is called by both  
set_address() and set_ipv6_addr(), and I _think_ 3/4 of set_sockaddr()  
is ipv6-only stuff but... I've used "ifconfig eth0"  
back in 2002 and this ifconfig implementation only has / parsing in the  
ipv6 path, and it seems to be doing something else...? I'm not familiar  
with ipv6 enough to understand what this is doing, so I'm trying to  
learn these funky corner cases I've never used so I can understand,  
untangle, and test...)

I've got a p9d server in progress, and I've dug up my mount  
implementation because I've had _three_ mount implementations submitted  
ot me now so I need to get that in...

Plus I still have a todo list of commands to triage that predate  
"pending" (vmstat, login, du, vconfig, mountpoint, free, chroot, cut,  
touch modinfo, expand) and some of them have shrapnel in lib/lib.c (for  
example "cut" added get_int_value() which is something lib/args.c  
already does...)

> PS: be sure to ignore "oksh", which is openbsd pdksh + the old pdksh
> configure + a GPL3 notice and a few unsafe hacks to make it build
> with glibc.

I grabbed the original massively stale version from 1999, on the theory  
there's probably less of it to read. "wc -l *.c" says the total is  
27180 lines, which is a couple solid days triaging right there.

But this weekend, go to visit my sister and the niecephews again...

> Also ignore "posh", a pdksh fork under GPL3 which focused on removing
> non-POSIX features, but doesn't support all the traps mandated by  
> or any interactive line editing.

I'm sticking with the ancient long-dead version, I think. I'm less  
likely to catch anything from it. :)

And really, I have the design of a new shell that I did a months of  
design work for (as in a couple hours every evening for about three  
months in early 2007). It's just not the kind of thing you want to  
start and stop repeatedly on, I want to do it all in one go and I have  
_not_ had time for it.

> > Date: Tue, 4 Jun 2013 22:46:57 +0530
> > From: Prasanna Balan <prazzb at gmail.com>
> > To: aboriginal at lists.landley.net
> > Subject: Re: [Aboriginal] Replacing bash with mksh
> > On 04/06/13, Rob Landley wrote:
> > > On 05/31/2013 03:00:09 AM, Niklas Larsson wrote:
> > > > Another nice thing with mksh is that it's the default shell in  
> Android
> > > > since Ice cream sandwich.
> > Have been reading about it... I am thinking of replacing my user  
> shell
> > from bash to mksh..need some more time to read up on it
> No real issues for most things; I've used mksh as login shell on my
> netbook for a few years, due to the bloat of modern bash with all
> extensions loaded.
> Even shell expressions (like a.{c,sh}), work the same.

So it's already better than the Defective Annoying SHell, then. :)

Which fork are you using?


More information about the Aboriginal mailing list