[Aboriginal] Replacing bash with mksh

idunham at lavabit.com idunham at lavabit.com
Mon Jun 10 00:33:06 PDT 2013


On Sat, Jun 08, 2013 at 02:00:49AM -0500, Rob Landley wrote:
> 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".
> 
> 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
> 192.168.1.42/24" 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...

So there are now four versions of mount floating around, none of which
are publicly available?

> 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...)
> 
modinfo seems to be good for uncompressed modules afaict.  
I'd write a test for it if I could figure out how to do one that works with 
all Linux hosts...but the corner cases it makes sense to check may not be 
present on many systems. (Coincidentally, toybox modinfo does the right
thing for "modinfo oss-usb" where busybox fails; oss_usb.ko is the file
name, it's part of the out-of-tree OSS4 code...)
Examples of test cases:
modinfo a-module -> a_module.ko
modinfo a_module -> a-module.ko
modinfo radeon
(mile long list of firmware that changes with each kernel version
follows)

> 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.

23460 for ksh-openbsd, patches applied.
So someone has achieved negative code growth.

> >> 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?

Debian/Ubuntu package, maintained by Thorsten Glaser (an upstream
developer.)
But it's also true of at least the Debian Squeeze pdksh package.
Of course, ostensibly "some non-portable" features get disabled when you use the
name "sh"...haven't tested which ones.

(BTW, dash is Debian's fork from 2002 of an ancient port of NetBSD's 
Almquist shell.  AFAIK it is technically conformant to POSIX, and even
supports a few bash-like features...but nowhere near all the ones people
use.)

Isaac


 1370849586.0


More information about the Aboriginal mailing list