mksh(1) R38c
This is the website of the MirBSD™ Korn Shell, an actively developed free implementation of the Korn Shell programming language and a successor to the Public Domain Korn Shell (pdksh).
|
This page is always accessible via a redirection at http://mirbsd.de/mksh, which is the canonical homepage URI, and in case the webserver is unreachable, the backup page will provide basic information. The FSF/UNESCO directory of Free Software lists mksh, too. There also is an mksh project page on ohlol. Get the Logo (SVG). |
Table of Contents
- Introduction and Licence
- Support (IRC, manual page, mailing lists, …)
- Installation
- Upgrade your packages from older mksh
- Inclusion in operating systems
- comparision with other shells
- Testsuite Results (regression tests)
- on version numbers – for packagers
- future plans
- ChangeLog
- information about old versions
Introduction
The current version of mksh is mksh R38c from 10 June 2009.
Thanks to “Der Verein trash.net” for sponsoring access to a Solaris 8 box. Thanks to HP TestDrive, which helps in keeping mksh portable to several Unixes and compilers, and track down some architecture- or glibc-specific bugs. Thanks to Julian “yofuh” Wiesener for just another account on a Sun E420 on Solaris 11β. Thanks to someone who prefers to stay anonymous due to tons of red tape for providing access to an AIX 5.3 system with gcc and xlC installed. Thanks to gnubber’s admin (Barry “bddebian” deFreese), as well as Samuel “youpi” Thibault, for providing shell access to a Debian GNU/HURD system. Thanks to Lucas “laffer1” Holt for ssh access to the MidnightBSD server. Thanks to Waldemar “wbx” Brodkorb for dropping his unused Zaurus SL-C3200 to someone who can actually make use of it to test mksh on OpenBSD. Thanks to Andreas “gecko2” Gockel for access to a couple of Debian and Macintosh boxen and an iPhone 3G. Thanks to Martin Zobel-Helas for an account on an Alpha system. Thanks to Bastian “waldi” Blank for access to an S/390 system and uploading mksh packages to Debian for quite some time. Also thanks to Otavio Salvador and Patrick “aptituz” Schönfeld for uploading a couple of my Debian packages. The Debian GNU/k*BSD and HURD developers were quite helpful in assisting and testing as well. Thanks to Thomas E. “TGEN” Spanjaard for access to both a NetBSD and a DragonFly system. Thanks to Josef “jupp” / “penpen” Schugt for testing mksh on a Digital Unix (OSF/1 V4.0) system from the Uni Bonn Physik CIP Pool. Thanks to DEChengst from #UnixNL for providing access to a HP/Compaq Tru64 (OSF/1 V5.1B) system, an OSF/1 V2.0 system and an Ultrix 4.5 system. Thanks to Adam “replaced” Hoka for a BSDi BSD/OS 3.1 ISO9660 image and offering to help with HP-sUX testing (now that HP TestDrive went down) and porting to Haiku. Thanks to André “naaina” Wösten for ssh on a QNX box. Thanks to Olivier Duchateau for testing on Slackware and Zenwalk GNU/Linux. (Did I miss anyone? Mail me if so. Some of these are past, anyway.)
What is mksh(1)? – Short answer: The MirBSD Korn Shell. Okay, but what exactly does it do, or why another shell? These questions will be answered below for the people interested. Right now, you only need to know that mksh is a DFSG-free and OSD-compliant (and OSI approved) successor to pdksh, developed as part of the MirOS Project as native bourne/POSIX/korn shell for MirOS BSD, but also to be readily available under other UNIX®-like operating systems.
The source code for mksh is available at the MirOS Project mirrors
as well as these of other operating system projects due to being included in these; however, we do not provide binaries.
Find instructions to build and install mksh below, or
ask your operating environment vendor to package and include mksh; we provide
assistance for this task if asked. Licencing permits this as long
as due credit is given to the authors and contributors and the copyright
notices are not removed in their entirety; modifying is allowed (but if
the result is still called mksh, it’s discouraged; talk with us if you
feel you have to modify mksh). The individual licences used are the MirOS
licence, and (for BSD compatibility on other oerating systems) the 3-clause
UCB licence and the ISC licence; full terms are
available via CVSweb. pdksh originally was public domain, with a few
exceptions, but these files are not part of mksh R21 or up. The mksh(1) author
(mirabilos) acknowledges the contributions of these people who dedicated pdksh
and oksh to the public, and asserts a collective copyright on the code.
All these licences are DFSG clean and conform to the OSD, and the MirOS
Licence is listed on the pages of the ifrOSS licence centre as well as
in the FSF/UNESCO Directory of Free Software. The MirBSD Korn Shell is OSI Certified
and its manual Open Knowledge.
To compile mksh, you will need a bourne or POSIX shell (Solaris
/bin/sh is enough, and the Z shell should work), a C compiler (at
the moment, only the one from the GNU Compiler
Collection works, but we’re attempting to change this), system and C
library header files and the standard C runtime. You will also need a set of
standard UNIX® tools on a supported operating system: any recent BSD; Darwin,
Apple Mac OSX; Interix (Microsoft® Services for Unix 3.5, maybe Subsystem for
Unix Applications on Win2003/Vista); GNU/Cygwin; UWIN; GNU/Linux (libc5,
glibc, dietlibc, µClibc, some klibc systems are tested), Debian GNU/kFreeBSD,
GNU/HURD or GNU/Linux; Sun Solaris (8, 9, 10, 11), OpenSolaris; AIX; IRIX;
HP-UX 11i; OSF/1; ULTRIX; Minix 3
To run the
regression test suite, you will need a not too antiquated Perl with POSIX.pm
as well as /bin/ed (whose installation is
strongly suggested anyway, because it’s the standard FCEDIT history
editor and standard UNIX® text editor), as well as a controlling terminal,
usually /dev/tty or provided from script(1) or GNU screen.
To use mksh, you only need the C runtime (and any supplemental libraries the binary was linked against) and, optionally, /bin/ed – for interactive use, a controlling terminal is highly recommended because job control does not work without one.
To make full use of mksh(1)’s interactive features, it is recommended to copy the dot.mkshrc file from the source distribution as ~/.mkshrc into the user’s home directory and let the user adjust it to suit his needs. The sample file configures a few aliases and shell functions as well as a sensible prompt ($PS1) and some csh-like directory stack functions and zsh-like hooks. Full use of this file requires a few special UNIX® tools. Note that $ENV must not be set for mksh(1) to parse the ~/.mkshrc file at startup.
Support
We provide an online manual page in HTML and PDF format. Reading books about Korn Shells in general is recommended as further help, but beware of the differences to other shells. Some ISBNs are listed at the end of the manual page.
If you require additional assistance or want to discuss bugs, features or enhancements, write to the mailing list (or subscribe to it). The mailing list can be reached via NNTP or at the MARC web archive (or GMane Loom) as well. Joining the IRC channel at Freenode (irc.freenode.net:6667) #!/bin/mksh (no joke, this is really the channel’s name) and #ksh (where you must distinguish AT&T ksh from mksh though) is recommended as well.
Installation
Skip to the section about being included in operating environments unless you really want to compile mksh from source yourself or create a package for your operating system of choice.
First off, you have to download the source code from any of the mirrors listed below, or any other mirror you know of. Official source code distributions are a cpio(1) compressed “old-style” (portable octal) archive, compressed with gzip(1) (zlib’s deflate algorithm) and digitally signed with gzsig(1) using the MirOS Project’s current signature key. Please verify the signature as well as the hashes and/or checksums below, so you’re sure the content is intact and the version number on the archive is correct. If you require source code in tar(1)’s “ustar” format, check the Debian Project for availability, although they often do not carry the latest version. The pax(1) utility (the POSIX Archiver) can extract from the CPIO distfile and is available even on a stock Microsoft® Windows® installation.
Known Mirrors
- https://www.mirbsd.org/MirOS/dist/mir/mksh/mksh-R38c.cpio.gz
- http://pub.allbsd.org/MirOS/dist/mir/mksh/mksh-R38c.cpio.gz
Checksums and Hashes
- RMD160 (mksh-R38c.cpio.gz) = d2a5f00a992e359f985b9023d9780c5283adb2e5
- TIGER (mksh-R38c.cpio.gz) = 8857775db4e60f66b03337f85a212f266890a71b5a284a54
- 860103691 276630 /MirOS/dist/mir/mksh/mksh-R38c.cpio.gz
- MD5 (mksh-R38c.cpio.gz) = 692192a6468b5f5c5e559756f1851766
- All official distfiles are gzsig(1)d.
Decompression
Use any of the following syntaxes to extract the distfile; you’ll get the idea soon. Some web browsers (prominently, Mozilla® and its derivates as well as Microsoft® Internet Explorer®) already inflate the distfile during download but do not remove the “.gz” extension; replace “gzip -dc” (gzcat) with “cat” if that happens for you.
The first example is using BSD paxtar (MirOS BSD, OpenBSD, NetBSD®), or “bsdtar” (DragonFly); the second and third use cpio(1) or pax(1) and are for most operating systems; the fourth is for Debian.
- $ tar xzf mksh-R38c.cpio.gz && cd mksh
- $ gzip -dc mksh-R38c.cpio.gz | cpio -mid && cd mksh
- $ gzip -dc mksh-R38c.cpio.gz | pax -r && cd mksh
Compilation
Now you’re in the source code directory; Build.sh does all the
magic for you. In theory, invoking the command
% /bin/sh ./Build.sh
should work. Relative paths can be used too, for example, instead of cd(1)ing
to the source directory, you could’ve done
% mkdir build; cd build; /bin/sh ../mksh/Build.sh
The build script requires a bourne shell (Solaris /bin/sh, the Heirloom sh, DEC OSF/1 V2.0 /bin/sh), korn shell (ksh, ksh88, ksh93, pdksh, mksh, oksh, maybe the MKS ksh), POSIX shell (posh, /usr/xpg4/bin/sh, ash, dash), or a super-set (GNU bash) to work; the Z Shell sometimes works as well, but the ULTRIX /bin/sh or the C shell (csh, tcsh) or “bsh” or a scripting shell like the wish won’t. Accepted arguments are:
- -combine – all-in-one build, recommended unless gcc is broken; ignored if $CC does not support "-fwhole-program --combine" (gcc4, R37+)
- -j – parallel build (mksh R31d and up)
- -llvm[=…] – compile to bytecode; option arguments (or, if none given, ‘-std-compile-opts’) are passed to LLVM opt (mksh R36b and up)
- -Q – be (only) a little less verbose
- -r – don’t try to build a pre-formatted version of the manual page using nroff(1) if found – recommended
Note on -j vs -llvm vs -combine: these three are mutually exclusive and, in this paragraph, listed in the order of preference, with the least preferred first (being -j) and the most preferred last (being -combine which achieves the best optimisations). It is sometimes possible to use -j together with -llvm to parallelise LLVM Bytecode generation, though.
The build script also honours the following environment variables:
- CC (gcc) – the C compiler used
- CFLAGS (-O2 / -xO2; on HP-UX/IA64 also -mlp64 / +DD64) – optimiser and other compiler flags used
- CPPFLAGS (no default) – additional cpp(1) flags
- LDFLAGS (set on AIX for libcrypt) – additional CCLD flags
- LIBS (-lcrypt on Interix; empty otherwise) – additional libraries to pull in
- NOWARN (-Wno-error / -errwarn=%none) – $CC option to disable bailing out at errors; used during mirtoconf checks
- NROFF (nroff; “nroff -c” with GNU groff) – the manual page processor used unless -r is given
- TARGET_OS (uname -s || uname) – the operating system to compile for; set this during cross compilation; valid: AIX BeOS (not yet) BSD/OS CYGWIN* Darwin DragonFly FreeBSD GNU (HURD) GNU/kFreeBSD Haiku (not yet) HP-UX Interix IRIX* Linux MidnightBSD Minix MirBSD NetBSD OpenBSD OSF1 Plan9 (not yet) PW32* (not yet) QNX SunOS syllable (not yet) ULTRIX UWIN*
- TARGET_OSREV (uname -r) – the operating system revision number for these that need it; currently: QNX (R38c+)
If CPPFLAGS contain any of the following definitions, the resulting binary will be compiled with a specific flavour:
- -DMKSH_SMALL – build a really small mksh(1), e.g. for embedded systems
- -DMKSH_ASSUME_UTF8=0 – do not use setlocale(3) or nl_langinfo(CODESET); do not assume the terminal is in UTF-8 mode (mksh R38c and up)
- -DMKSH_ASSUME_UTF8 – do not use setlocale(3) or nl_langinfo(CODESET); assume the terminal is always in UTF-8 mode
- -DMKSH_BINSHREDUCED – include code to automatically “set -o posix” to reduce functionality if called as sh or -sh
- -DMKSH_CLS_STRING – the string to send to the terminal to clear the window (default: "\033[;H\033[J")
- -DMKSH_CONSERVATIVE_FDS – use less filedescriptors (32/10 ipv 56/24), e.g. if the system supports few (mksh R37c and up)
- -DMKSH_MIDNIGHTBSD01ASH_COMPAT – parse “--” on the shell command line like MidnightBSD 0.1 /bin/sh but different from all other shells; requires -DMKSH_BINSHREDUCED (mksh R38 and up)
- -DMKSH_NOPWNAM – if MKSH_SMALL is not set, still omit getpwnam(3) calls in order to not pull in the nsswitch or PAM libraries
- -DMKSH_NOVI – if this or MKSH_SMALL is set, the vi command line editing mode (which is orphaned anyway, yet functional) is omitted
- -DMKSH_NO_LIMITS – don’t compile the ulimit code (R38c+)
- -DUSE_REALLOC_MALLOC=0 – if realloc(NULL, n) is not equivalent to malloc(n) (n > 0) as ANSI C89 prescribes
You can override certain mirtoconf checks by setting environment variables
like HAVE_REVOKE=0 (default for Linux) – if these are set to 0 or 1,
the values are used; if unset, the values are probed (unless overridden by a
different check, such as MKSH_SMALL), if set to ‘x’ the probe is forced.
Useful items to enable/disable are HAVE_MKNOD and HAVE_READLINE (set to 0 to
disable, set to x to re-enable for MKSH_SMALL), HAVE_SETLOCALE_CTYPE (set to
0 if you know that it won’t ever return UTF-8), HAVE_PERSISTENT_HISTORY (0 to
not include this feature), HAVE_FLOCK_EX (if flock or mmap do not work on
files), HAVE_EXPSTMT (if ({ expression statements are buggy).
Operating Environment specific notes
Compiler: ACK
Support for ACK on Minix 3 has been added in mksh R37c with a workaround a known ACK bug (the "const" bug); it is now perfectly usable. Support for other ACK versions or targets can be user-contributed.
Compiler: Borland C++ Builder
This compiler is somewhat supported in mksh R30 with UWIN’s cc wrapper. (We haven’t been able to produce a working executable though.)
Compiler: DEC/Compaq/HP C for OSF/1 and Tru64
This compiler is fully supported with mksh R33b (partial support did appear earlier).
The ucode based compiler, linker and loader for Digital UNIX (OSF/1) V2.0 on MIPS is supported since mksh R36. It may, however, be forced to link statically to work around a bug in the toolchain.
Compiler: Digital Mars
This compiler is somewhat supported in mksh R30 with UWIN’s cc wrapper and a few kludges. (We haven’t been able to produce a tested executable though, due to general stability issues with the UWIN platform.)
Compiler: GCC
The GNU C Compiler 1.42, 2.7.2.1, 2.7.2.3, egcs (gcc 2.95) and the GNU Compiler Collection (gcc 3.x, 4.x) are known to work, but not all versions work on all targets. Specific C flags, known extensions, etc. are autoprobed; cross-compilation works fine. Use of gcc 4.x is discouraged because of several dangerous changes in how the optimiser works; it is possible to work around their trading off reliability for benchmark-only speed increases, but because mksh developers do not use gcc 4.x this will have to be user-contributed. On the other hand, gcc 3.x (in some cases 2.x) is the best choice for compiling mksh.
On BSDi BSD/OS, where gcc 1.42 and gcc 2.7.2.1 are available, the cc(1) manual page mentions that gcc 1.42 produces more reliable code, so we recommend to build mksh with CC=cc (gcc1) instead of CC=gcc or CC=gcc2 there instead.
Since mksh uses ProPolice, the Stack-Smashing Protector, some GCC versions’ compilates require additional shared libaraies.
Compiler: HP C/aC++
HP’s C compiler (/usr/bin/cc on HP-UX) is supported in mksh R30 and above; on IA64, only the LP64 model can be used; mksh segfaults in the ILP32 module (or rather, the system libraries do, I think), so it is default. PA-RISC too works fine, so this compiler is a primary choice.
Compiler: IBM XL C/C++ / VisualAge
IBM xlC 9.0 on AIX 5.3 is supported in mksh R30 and above.
IBM xlC 8.0 on Linux/POWER and IBM xlC 6.0β on MacOS X are on the TODO.
IBM xlC 7.0 on AIX 5.2 is supported in mksh R35c and above.
Compiler: Intel C/C++/Fortran
ICC emulates GCC quite well (too well for my taste), is fully supported in mksh R30 and above on several platforms, but spits out lots (and I mean huge ugly lots) of bogus warnings during compile. We’re not going to work around these; let Intel fix their compiler instead. Some of these warnings were even responsible for bugs in mksh.
I could not get the Intel Compiler 10 for Windows® to work.
mksh enables the ICC stack protector option automaticaly. Compilates usually require the Intel shared libraries to be around.
Compiler: LLVM
Apple llvm-gcc from Xcode 3.1 had full success with mksh R34.
Vanilla llvm-gcc works fine as well.
Vanilla llvm-clang starting at r58935 produces working code with mksh R36b and up.
Compiler: Microsoft® C/C++
Support for the Microsoft® C Compiler on Interix and UWIN, with the respective /usr/bin/cc wrappers, appeared in mksh R30. The following product versions have been tested:
CL.EXE: Microsoft (R) 32-bit C/C++ Standard Compiler Version 13.00.9466 for 80x86
LINK.EXE: Microsoft (R) Incremental Linker Version 7.00.9466
(both are part of the .NET Common Language Runtime redistributable)
CL.EXE: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86
LINK.EXE: Microsoft (R) Incremental Linker Version 8.00.50727.42
(both are part of Visual Studio 2005 C++ Expreß)
You’ll have to change Interix’ cc(1) wrapper though: replace /Op
with /Gs- to disable the stack checks (missing support in libc
for them, they used to be off by default) and remove /Ze.
On Interix (SFU 3.5), this compiler is maturely usable and a good choice.
On GNU/Cygwin, using wgcc it might be possible to use this compiler. I could not test that yet, though.
On UWIN, this is usable as well.
Compiler: MIPSpro
Support for SGI’s MIPSpro compiler on IRIX appeared in mksh R33b.
Compiler: nwcc
Support for nwcc appeared in mksh R36b, although the compiler itself is still slightly broken. Even if the compiler can be built and can build executables, it produces bogus warnings and wrong code.
Compiler: PCC (BSD)
Support for the Caldera/SCO UNIX® based, BSD-licenced portable C compiler in the ragge version has been added with mksh R31d. Versions from end of April 2008 onwards are known to work reliably, even with -O enabled.
The compiler itself rarely works on GNU/Linux or Darwin due to GNUisms, assembler problems, etc. though.
Compiler: SUNpro
Support for the SUN Studio 12 compiler (cc 5.9) as well as cc 5.8 appeared in mksh R30; other versions might be supported as well. This compiler is a primary choice.
Using SUNWcc on MirBSD
$ SP=/home/tg/Misc/suncc/sunstudio12 $ LD_LIBRARY_PATH=$SP/prod/lib/sys:$SP/prod/lib CC=$SP/prod/bin/cc \ LDFLAGS="-Yl,$SP/S" sh /usr/src/bin/mksh/Build.sh -r
Compiler: tcc (Tiny C)
Support for Fabrice Bellard’s tcc appeared in mksh R31, although its unability to do ‘-E’ in older versions gave us some headache, and glibc currently makes it impossible to link the final executable.
Compiler: TenDRA (maybe Ten15 too)
Support for TenDRA appeared in mksh R31 and appears to be solid; mksh uses the ‘system’ profile for compiling by default. Users who wish to build mksh with a different profile are welcome to help to port it.
See ULTRIX for an example of getting a ‘POSIX’ profile to work.
Compiler: DEC ucode (MIPS CC)
Since mksh R33c, ucode on Ultrix is fully supported.
Toolchain: dietlibc
Fefe’s dietlibc works in mksh R34, although his opinion towards certain standards, such as caddr_t, strcasecmp(3), etc. are weird.
Toolchain: klibc
klibc (with stock klcc as compiler wrapper) works if the patch from the Debian bug reports is applied and -DMKSH_NO_LIMITS is used to build mksh(1).
OS: AIX
Support for AIX with xlC appeared in mksh R30.
If passing custom LDFLAGS, don’t forget the export symbols required for using libcrypt. If passing custom LIBS, don’t forget -lcrypt.
OS: BeOS / Haiku
ahoka@ has begun porting, but it doesn’t work yet.
OS: BSDi BSD/OS
BSD/OS 3.1 works fine with mksh R33.
OS: GNU/Cygwin
This operating environment is supported as much as it adheres to standard POSIX/SUSv3 conformant things. No workarounds for .exe suffixes or other platform-specific quirks have been or will be added.
OS: Darwin / Mac OSX
Works pretty well.
OS: DragonFly BSD
Perfect choice. Note /bin/sh compatibility needs a quirk.
OS: FreeBSD
Perfect choice. Note /bin/sh compatibility needs a quirk.
OS: GNU/HURD
This operating system is supported (on i386) since R29 but not well tested. mksh is part of Debian GNU/HURD, so it is expected to work.
OS: GNU/k*BSD
This operating environment has been supported for quite a while as part of Debian and somewhat tested.
OS: GNU/Linux
While POSIX does not apply to “GNU’s Not Unix”, the FHS (ex-FSSTND) does; please convince your distributor to move ed to /bin/ed if not already done. Manual page installation paths are not standardised in older distributions either.
Besides glibc (GNU libc), dietlibc (from Fefe), µClibc (embedded), klibc (for initramfs) and libc5 (on Linux 2.0.38) work, but locale detection is not automatic for some of them.
mksh can be used as /bin/sh on Debian and similarly strict distributions, which allow to use e.g. ash/dash there as well.
OS: HP-UX
Support for HP-UX with GCC appeared in mksh R29 and works with HP’s C compiler and is no longer experimental in mksh R30. Please use stty(1) to make the terminal sanely usable.
If passing custom CFLAGS, don’t forget -mlp64 (GCC) or +DD64 on Itanium.
OS: Interix
We have only tested SFU 3.5 on Windows® 2000, not SUA on Windows® 2003 SR1 or the version integrated into Vista.
As the Unix Perl which comes with Interix is too old, and the ActiveState Perl has… other issues, to run the regression tests, please install Perl from NetBSD® pkgsrc® instead.
As of mksh R30, the native compiler (cc(1)) is supported in addition to gcc, calling Microsoft C. Do not use the c89(1) wrapper.
If passing custom LIBS, don’t forget to add -lcrypt or any other library providing arc4random(3).
mksh can replace /bin/ksh and /bin/sh without any problems.
OS: IRIX
Support for IRIX64 6.5 appeared in mksh R33b.
OS: MidnightBSD
mksh is part of MidnightBSD 0.2-CURRENT and above and used as native /bin/ksh; it can be used as /bin/sh as well with a quirk.
MidnightBSD 0.3 uses mksh as /bin/sh indeed.
OS: Minix
Minix 3 is supported starting mksh R37b (gcc), R37c (ACK/adk cc). Minix 1 and Minix 2 will never be supported due to size constraints on 16-bit platforms, unless a user contributes code.
Minix 3 contains a /usr/bin/ed which, even if copied to the correct directory (/bin), will fail the regression tests due to bugs. A modern ed(1), if compiled, might help with it similarily to QNX, but MirBSD ed needs very many patches, so this was not tried.
OS: MirBSD
Perfect choice. This is where mksh comes from.
OS: NetBSD
Perfect choice.
Starting with NetBSD 1.6, mksh can replace /bin/ksh and /bin/sh without any problems. On NetBSD 1.5, mksh can only replace /bin/ksh safely.
OS: OpenBSD
The setlocale(3) call in OpenBSD’s libc will always return the “C” locale and therefore has been disabled by default.
mksh can replace /bin/ksh and /bin/sh without any problems. mksh is supposed to be a superset of oksh (except GNU bash-style PS1, weird POSuX character classes, and an incompatible ulimit builtin change).
OS: DEC/Compaq OSF/1, Compaq/HP Tru64
Digital Unix is somewhat supported using gcc as of mksh R31b. With mksh R33b, many more versions and the native compiler work.
OS: Plan 9
Plan 9 is not supported yet – we were able to create an executable, but it did not return to the prompt after running a non-builtin command; this is job control issues, and patches are welcome. (Note this is for R37 and below; R37b might actually work, but someone would have to test this.)
Due to the unavailability of ttys, job control will never be supported.
The APE (ANSI’n’POSIX Environment) is required to build mksh; I don’t remember which compiler I used, but I think it was GCC.
OS: PW32 on Win2k
PW32 is not supported yet – killpg(3) is missing, and it’s possible that PW32 and Minix 3, at least, need job control disabled or worked around. Maybe peek at how ash/bash for PW32 do it. gcc works.
OS: QNX/Neutrino
QNX/Neutrino (Perl: “nto”) support appeared in mksh R36b.
The QNX ed(1) fails the regression tests due to being broken; compile the MirBSD ed and place it in /bin/ to fix this.
OS: Solaris
Solaris is full supported since “forever” with gcc, and since mksh R30 with Sun’s C compiler. Both 32-bit and 64-bit modes work; 64-bit mode is not enabled by default by Build.sh, you must do that manually by passing CFLAGS of -O2 -m64 or -xO2 -xarch=generic64.
Solaris does not come with Berkeley mdoc macros for nroff, so using the HTML or PDF versions of the manual pages or pregenerating a catman page on another OS is required.
OS: Syllable Desktop
This does not yet work due to a signal passing bug in the AtheOS kernel, we were told by their developers. However, mksh R33 is at the same level of support as Plan 9 now.
Chances are a more recent mksh works with a more recent Syllable.
Syllable Server will work, as it is, at the moment, “just” a GNU/Linux distribution with a different GUI. This may change though.
OS: ULTRIX
Even on ULTRIX 4.5, mksh R33c works fine. The system ksh must be used for running the Build.sh script, though.
You however must pass the -YPOSIX option to the ucode compiler, as the default -YBSD profile produces a broken executable (spins instead of starting up), and the -YSYSTEM_FIVE profile does not even compile. See TenDRA for another OE which has issues with different OE profiles. (Build.sh takes care of this automatically.)
OS: UWIN-NT
Compilation of mksh R30 on UWIN works with several compilers (bcc, dmc, msc – I could not get gcc-egcs, gcc-2.95, gcc-mingw, icc to work) but the platform itself is very flakey, and even some regression tests crash, due to target limitations apparently. Within these limits, mksh is usable.
After compiling
The Build.sh script generates an executable (“mksh”, except on
GNU/Cygwin, where it is called “mksh.exe”), a shell script to use the newly
built mksh to run the regression test suite (“test.sh”), and (unless the
-r option was given) a pre-formatted manual page (“mksh.cat1”).
It also lists installation instructions unless -Q was provided.
Now it’s the time to run
% ./test.sh -v
in order to see if the shell works.
To actually install mksh, copy the binary to some place in $PATH, i.e. /bin/mksh, $HOME/.bin/mksh, /usr/local/bin/mksh, or whatever your packaging system wants; strip it and run chmod 555 on it. (This can easily be achieved with install(1) – on Solaris, this is /usr/ucb/install not /usr/bin/install – with the arguments -c, -s, -m 755¹, and -o/-g. ① with 555, strip(1) cannot write the file any more, chmod 555 afterwards.) Also append its installation path to /etc/shells, install the dot.mkshrc file (usually alongside with the copyright file and other documentation), copy it to /etc/skel/.mkshrc if your operating environment has this means to include default dotfiles; install either the catman page (mksh.cat1) to, for example, /usr/share/man/cat1/mksh.0, or the mdoc page (mksh.1) to the standard location (/usr/share/man/man1/ or /usr/man/man1/ or whatever your operating environment requires). The manual page requires the Berkeley mdoc macros (either the BSD or the GNU groff version) to be installed during formatting time.
Note that a ~/.mkshrc file will not be executed if $ENV is set and not empty, nor is there an /etc/mkshrc.
For packagers: Upgrades
Note: This is not the ChangeLog, these are the packager-visible upgrade notes regarding changes in the build system (Build.sh and friends, compiler support, packaging conventions, bad examples, etc).
mksh R38c adds QNX fixes, build system fixes, and the ability to use -DMKSH_ASSUME_UTF8=0 to skip the environment checks (leading to one (supposedly un-)expected regression test failure). Use -DMKSH_NO_LIMITS to skip the ulimit builtin (klibc).
mksh R38b works on QNX 6.4 out of the box.
mksh R38 offers -DMKSH_MIDNIGHTBSD01ASH_COMPAT and users should be warned about the “!string” line and UTF-8 mode changes.
mksh R37c now honours -DMKSH_CONSERVATIVE_FDS and ACK. The regression test suite keeps LOCPATH around.
mksh R37b now honours -DMKSH_UNEMPLOYED for the jobless mode required on, at least, Minix 3.
Freshmeat announcements have ceased because the site switched to a very user-unfriendly HTML (especially Lynx). Use the RSS feed instead.
mksh R37 has a new ‘-combine’ Build.sh option. The -DMKSH_AFREE_DEBUG flag is gone due to a new allocator, which however honours -DUSE_REALLOC_MALLOC=0.
Inclusion in other operating systems
- Debian GNU/Linux, GNU/HURD and GNU/kFreeBSD have an mksh package maintained by the MirOS Project and uploaded (sponsored) by Bastian “waldi” Blank, Otavio Salvador, and Patrick Schönfeld; the debconf questions were taken from dash. We do not provide an inofficial source package any longer.
- Gentoo GNU/Linux has an mksh ebuild created by Hanno Böck.
- Fedora GNU/Linux 8, 9, 10, 11, and RHEL 4 and 5 (via EPEL) now officially contain an mksh package (spec file). There are some Instructions for activating EPEL (RHEL only), then just type yum install mksh.
- The OpenSuSE Build Service provides an mksh package inside the shells repo, thanks to Pascal “loki” Bleser and Marcus “darix” Rückert; the RPMs are available for various distributions as well as as SRPM (source RPM). The inofficial portable SRPM has been retired; the OBS SRPM has been changed to be buildable on Debian and MirBSD as well as include the contributed arc4random.c file. There are more downloads available, just browse a little.
- Fink delivers an mksh package from Andreas “gecko2” Gockel.
- SMGL (Sourcemage GNU/Linux) has an mksh spell in their grimoire, developed by the MirOS Project together with Daniel “morfic” Goller, updated by Thomas “sobukus” Orgis and Vlad “Stealth” Glagolev.
- In the FreeWRT Embedded GNU/Linux Appliance Development Kit (meta distribution), the mksh package is maintained by us. mksh is also the default shell in FreeWRT trunk (soon to be 1.1) and above.
- OpenWrt Embedded GNU/Linux Distribution also provides mksh on ADSL/WLAN routers thanks to Felix “nbd” Fietkau.
- Ubuntu GNU/Linux, the grml (and grml64) Live-CD, and other Debian derivates also have an mksh package; Knoppix, SIDUX, Nexenta OS (GNU/Solaris), and grml-small do not contain or offer mksh. Note: We need URLs to the packages for these, can anyone provide any?
- Arch GNU/Linux users can install an mksh package by Daniel “homsn” Hommel.
- FreeBSD® Ports (for FreeBSD, very old DragonFly BSD versions and DesktopBSD) also have a port created by Andreas “ankon” Kohn and kept up to date by Martin “miwi” Wilke. It is unknown if this applies to PC-BSD too, but there’s no mksh PBI (yet?).
- MidnightBSD uses mports, a derivate of FreeBSD® ports. Naturally, they deliver mksh as well. MidnightBSD 0.2-CURRENT from 18th August 2007 onwards has mksh as both /bin/mksh and /bin/ksh, i.e. it is the default MidnightBSD Korn shell. From 29 March 2009 onwards, it is also the default /bin/sh (since MidnightBSD 0.3).
- NetBSD® pkgsrc® (native also on recent DragonFly BSD; available for many other operating systems as well) has a package created by us and kept up to date by Blair Sadewitz and Adam “replaced” Hoka. We do not provide an inofficial source package any longer.
- The Desktop NetBSD project also contains mksh; see the source of their meta package. This will provide their users with a modern, fast, secure, featureful shell and enhance the experience.
- Beastiebox also comes with mksh as an option. It’s NetBSD® based, mostly.
- The MirPorts Framework brings mksh to OpenBSD, Mac OSX and Interix as well as older MirOS BSD versions, which have mksh as native Korn Shell.
- OpenBSD ports do not package mksh, but an inofficial port is available.
- ChinaLinux mirrors (and apparently packages) mksh.
- Some US-American Apple Users’ Group (the HMUG) packages mksh for Darwin, too.
- Frugalware Linux contains a broken mksh package; the build logs show the problem is on their side. (XXX Someone has any URL for us?)
- Slackware and Zenwalk GNU/Linux had once been targeted to be packaged by Olivier Duchateau, but we don't know the current state (XXX)
- There are probably many more, please drop us a note!
- Softpedia lists mksh, just like the FSF/UNESCO directory.
These packages are not official and have not always been tested by mksh developers; please keep this in mind.
Other Shells and more
mksh is a successor of pdksh but not affiliated with the pdksh developers or contributors. mksh is not affiliated with the AT&T Korn Shell, its past or present owners, other than that both attempt to implement the Korn Shell programming language.
mksh targets users who desire a compact, fast, reliable, secure shell not cut off modern extensions; a shell with Unicode support; an actively developed, current, and portable product; one with developers that listen to their users’ requests and implement them if they actually make sense.
mksh aims to replace pdksh in all but very rare use cases (such as support for checking the Unix mbox) and in all operating environments (thus including patches from pdksh on e.g. Debian).
Differences
mksh is a direct descendant from the OpenBSD /bin/ksh and contains all of its bug fixes and enhancements except the “GNU bash-like $PS1” and “POSIX character class support in globbing” changes and the incompatible “ulimit can handle multiple limits in one invocation” difference. Some of the more weird diffs in oksh have not been merged either. The DeliLinux developer who is responsible for packaging oksh for GNU/Linux should instead use mksh and port that diff over (be careful to not break the fixes to the command line editing modes, these are subtilely broken in OpenBSD). Even better, the OpenBSD people should not only commit a port of mksh but replace their ksh with it (optionally retaining that GNU bash-like $PS1 stuff). The set -o emacs-usemeta command is no longer needed because the emacs editing mode has been changed for Unicode/UTF-8 mode, which adds a new set -o utf8-hack mode. The set -o sh command has been completely removed, set -o posix merely turns off brace expansion as side effect. There is no limit (well, 2³² – for now…) on array sizes any more. Many bugs and security holes have been closed in mksh and are still in oksh and OpenBSD ksh. The user interface has much less bugs and surprises; emacs editing mode is enabled by default. In contrast to oksh, set -o arc4random can be used to control which generator for $RANDOM is used.
mksh is the heir of pdksh and contains all the latest fixes from upstream (so ca. 1995) and Debian. It is the only pdksh derivate currently being under active development. See above for other differences. The code really has been cleaned up and no longer contains any material under licences more restrictive than the BSD licence.
AT&T ksh88 and ksh93 compare to mksh substantially, but share no code; the user interface is slightly different especially for ksh88; many editing commands work (only slightly) differently as well. mksh implements many, but by far not all, ksh93 features, but most ksh88 features. No floating point. The last command of a pipeline is executed in a subshell.
mksh can do many things GNU bash can’t, for example better arrays, the ksh Co-processes, etc. but is much faster and smaller. In contrast to bash, mksh is still being actively developed (bash almost only receives small changes or weird stuff like programmable tab completion). GNU bash’s array initialiser syntax is not yet supported. We don’t aim at being fully bash compatible, but some of the surprises for converts will be removed. Funnily, bash4 now contains some things first introduced in mksh.
The Z shell (zsh) isn’t even remotely ksh compatible in its “emulate ksh” operation mode, and we don’t compare to it.
mksh is mostly bourne shell compatible (but ^ as alias for | is
not supported, like most modern shells). mksh is also POSIX sh compatible.
Some constructs are not supported, for example
((foo; bar) 2>&1 || baz)
which has to be rewritten as
( (foo; bar) 2>&1 || baz)
because ((…)) is shell arithmetics;
brace expansion is turned on by default; etc.
mksh R33 supports more (later versions even more) bash/ksh93/zsh constructs than its predecessors; sometimes, not all cases (e.g. applying string trimming on arrays) are supported, but you probably will not notice that.
Official Testing
The MirOS Project has tested mksh on the following operating systems, asked people to test, and hunted mksh down in these packaging systems:
Development Versions post release
- – tests by the project, using Build.sh –
- Debian GNU/Linux sid 2.6.26-1-xen-amd64 (amd64 gcc4.5.0-r147610 gcc-snapshot_20090516-1) but -combine is broken again *sigh…*
- – other build system integration –
Current Release
- – tests by the project, using Makefile –
- MirOS #10-current (i386 gcc3.4.6)
- MirOS #10-current (sparc gcc3.4.6)
- – tests by the project, using Build.sh –
- MirOS #10-current (i386 clang58935mp0 llvm58935mp0)
- MirOS #10-current (i386 clang58935mp0 opt+llc+llvm58935mp0)
- MirOS #10-current (i386 llvmgcc4.2.1-Apple_5627mp2 llvm58935mp0)
- MirOS #10-current (i386 llvmgcc4.2.1-Apple_5627mp2 opt+llc+llvm58935mp0)
- MirOS #10-current (i386 pcc20081028-MirPorts-1)
- MirOS #10-current (i386 pcc20090522-cvs)
- MirOS #10-current (i386 SUNWcc5.9 Linux_i386 2007/05/03, GNU ld 2.13.90.0.2 20020802)
- BSDi BSD/OS 3.1 #4 M300-043 (i386 gcc2.7.2.1)
- BSDi BSD/OS 3.1 #4 M300-043 (i386 gcc1.42)
- DragonFly 1.9-DEVELOPMENT Feb 17, 2007 (i386 gcc3.4.6)
- MidnightBSD 0.3-CURRENT (i386 gcc3.4.6-20080430)
- DEC OSF/1 X2.0-8 (Rev. 155) (mips cc3.0 ucode ld3.0) without testsuite check
- DEC ULTRIX 4.5 0 RISC (mips cc3.0 ucode ld3.0)
- HP Tru64 OSF/1 V5.1B 2650 (alpha Compaq C V6.5-011 Rev. 2650)
- HP Tru64 OSF/1 V5.1B 2650 (alpha gcc2.97-tru64-010710 alphaev56)
- Solaris 8 Generic_117350-41 sun4u (sparc gcc3.4.3)
- Solaris 8 Generic_117350-41 sun4u (sparc64 gcc3.4.3)
- Solaris 10 Generic_137111-08 sun4u (sparc gcc3.4.6)
- Solaris 10 Generic_137111-08 sun4u (sparc64 gcc3.4.6)
- Solaris 10 Generic_137111-08 sun4u (sparc:V8+ SUNWcc5.9 124867-08 2008/10/07, ld 5.10-1.489)
- Solaris 10 Generic_137111-08 sun4u (sparc64 SUNWcc5.9 124867-08 2008/10/07, ld 5.10-1.489)
- Cygwin_NT-5.0 1.5.25(0.156/4/2) 2008-04-17 12:11 i586 win2kSP2 (i386 gcc3.4.4)
- Debian GNU 5.0 sid GNU-Mach 1.3.99/Hurd-0.3 i686-AT386 (i386 gcc4.3.1-7)
- CentOS GNU/Linux 5.2 2.6.18-92.1.18.el5xen (amd64 gcc4.1.2-44)
- Debian GNU/Linux 4.0 etch 2.6.18-6-686 (i386 gcc1:3.3.6-15)
- Debian GNU/Linux 4.0 etch 2.6.18-6-686 (i386 gcc4.1.1-21)
- Debian GNU/Linux 4.0 lenny 2.6.18-6-686 (i386 gcc4.1.2-25)
- Debian GNU/Linux 4.0 lenny 2.6.18-6-686 (i386 gcc4.3.2-1.1)
- Debian GNU/Linux 4.0 lenny 2.6.18-6-686 (i386 TenDRA-4.1.2-18)
- ecce!GNU/Linux 1.00 2.0.38a (i386 libc5 gcc2.7.2.3) except locale support
- Minix 3 3.1.4~r4203? (i386 ACK)
- Minix 3 3.1.4~r4203? (i386 gcc)
- – other build system integration –
- See the Inclusion section for general information
- Debian GNU/kFreeBSD sid 7.1-1-686 (i386 gcc4.3.3-5) by ganymede1 buildd via Debian
- Debian GNU/kFreeBSD sid 7.1-1-amd64 (amd64 gcc4.3.3-5) by ganymede2 buildd via Debian
- Debian GNU sid GNU-Mach 1.3.99/Hurd-0.3 i386-AT386 (i386 gcc4.3.3-5) by mozart buildd via Debian
- Debian GNU/Linux sid 2.6.26-1-alpha-generic (alpha gcc4.3.3-5 +glibc +dietlibc) by goedel buildd via Debian
- Debian GNU/Linux sid 2.6.26-rc5-iop32x armv5tel (armel gcc4.3.3-5) by ALL6500 buildd via Debian
- Debian GNU/Linux sid 2.6.26-1-parisc (hppa gcc4.3.3-5 +glibc +dietlibc) by penalosa buildd via Debian
- Debian GNU/Linux sid 2.6.26-2-amd64 (i386 gcc4.3.3-7 +glibc +dietlibc) by puccini buildd via Debian
- Debian GNU/Linux sid 2.6.18-dsa-mckinley (ia64 gcc4.3.3-5 +glibc +dietlibc) by mundy buildd via Debian
- Debian GNU/Linux sid 2.6.25-rc3-00000-g84d8498-dirty (mips gcc4.3.3-5 +glibc +dietlibc) by ball buildd via Debian
- Debian GNU/Linux sid 2.6.24.1 (mipsel gcc4.3.3-5 +glibc +dietlibc) by rem buildd via Debian
- Debian GNU/Linux sid 2.6.26-1-powerpc64 (macppc gcc4.3.3-7 +glibc +dietlibc) by praetorius buildd via Debian
- Debian GNU/Linux sid 2.6.26-1-s390x (s390 gcc4.3.3-5) by debian-31.osdl.marist.edu buildd via Debian
- Debian GNU/Linux sid 2.6.28.7 (sparcV8 gcc4.3.3-5 +glibc +dietlibc) by lebrun buildd via Debian
- Fedora GNU/Linux Core 9 2.6.18-128.1.1.el5 (i386 gcc4.3.0-8) by x86-4 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 9 2.6.18-128.el5 (macppc gcc4.3.0-8) by ppc8 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 9 2.6.18-128.el5 (ppc64 gcc4.3.0-8) by ppc10 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 9 2.6.18-128.1.1.el5 (amd64 gcc4.3.0-8) by x86-5 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 10 2.6.18-128.1.1.el5 (i386 gcc4.3.2-7) by x86-6 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 10 2.6.18-128.el5 (macppc gcc4.3.2-7) by ppc6 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 10 2.6.18-128.el5 (ppc64 gcc4.3.2-7) by ppc4 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 10 2.6.18-128.1.1.el5 (amd64 gcc4.3.2-7) by x86-1 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 11 2.6.18-128.1.1.el5xen (i386 gcc4.4.0-0.31) by xenbuilder2 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 11 2.6.18-128.el5 (macppc gcc4.4.0-0.31) by ppc2 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 11 2.6.18-128.el5 (ppc64 gcc4.4.0-0.31) by ppc9 buildd via Koji/EPEL packager
- Fedora GNU/Linux Core 11 2.6.18-128.1.1.el5 (amd64 gcc4.4.0-0.31) by x86-2 buildd via Koji/EPEL packager
- Red Hat GNU/Linux RHEL 4 2.6.18-128.1.1.el5xen (i386 gcc3.4.6-10) by xenbuilder2 buildd via Koji/EPEL packager
- Red Hat GNU/Linux RHEL 4 2.6.18-128.el5 (macppc gcc3.4.6-10) by ppc3 buildd via Koji/EPEL packager
- Red Hat GNU/Linux RHEL 4 2.6.18-128.1.1.el5xen (amd64 gcc3.4.6-10) by xenbuilder2 buildd via Koji/EPEL packager
- Red Hat GNU/Linux RHEL 5 2.6.18-128.1.1.el5xen (i386 gcc4.1.2-44) by xenbuilder2 buildd via Koji/EPEL packager
- Red Hat GNU/Linux RHEL 5 2.6.18-128.el5 (macppc gcc4.1.2-44) by ppc2 buildd via Koji/EPEL packager
- Red Hat GNU/Linux RHEL 5 2.6.18-128.1.1.el5xen (amd64 gcc4.1.2-44) by xenbuilder2 buildd via Koji/EPEL packager
- OpenSUSE GNU/Linux 10.3 2.6.27.21-0.1-xen (i386 gcc4.2.1) by build16 buildd via OBS SRPM package
- OpenSUSE GNU/Linux 10.3 2.6.27.21-0.1-xen (amd64 gcc4.2.1) by build19 buildd via OBS SRPM package
- OpenSUSE GNU/Linux 11.0 2.6.27.21-0.1-xen (i386 gcc4.3.1-20080507-r135036) by build20 buildd via OBS SRPM package
- OpenSUSE GNU/Linux 11.0 2.6.27.21-0.1-xen (amd64 gcc4.3.1-20080507-r135036) by build19 buildd via OBS SRPM package
- OpenSUSE GNU/Linux 11.1 2.6.27 (i386 gcc4.3.2-r141291) by build24 buildd via OBS SRPM package
- OpenSUSE GNU/Linux 11.1 2.6.27 (amd64 gcc4.3.2-r141291) by build14 buildd via OBS SRPM package
- SLES GNU/Linux 9 2.6.27.21-0.1-xen (i386 gcc3.3.3) by build24 buildd via OBS SRPM package
- SLES GNU/Linux 9 2.6.27.21-0.1-xen (amd64 gcc3.3.3) by build14 buildd via OBS SRPM package
- SuSE GNU/Linux Factory 2.6.29 (i386 gcc4.3.3-r144878) by build16 buildd via OBS SRPM package
- SuSE GNU/Linux Factory 2.6.29 (amd64 gcc4.3.3-r144878) by build24 buildd via OBS SRPM package
- CentOS GNU/Linux 5 2.6.27.21-0.1-xen (i386 gcc4.1.2-14) by build14 buildd via OBS SRPM package
- CentOS GNU/Linux 5 2.6.27.21-0.1-xen (amd64 gcc4.1.2-14) by build18 buildd via OBS SRPM package
- Fedora GNU/Linux 9 2.6.27.21-0.1-xen (i386 gcc4.3.0-8) by build12 buildd via OBS SRPM package
- Fedora GNU/Linux 9 2.6.27.21-0.1-xen (amd64 gcc4.3.0-8) by build15 buildd via OBS SRPM package
- Fedora GNU/Linux 10 2.6.27.21-0.1-xen (i386 gcc4.3.2-7) by build11 buildd via OBS SRPM package
- Fedora GNU/Linux 10 2.6.27.21-0.1-xen (amd64 gcc4.3.2-7) by build24 buildd via OBS SRPM package
- Mandriva GNU/Linux 2008 2.6.27.21-0.1-xen (i386 gcc4.2.2-0.RC.1mdv2008.0) by build24 buildd via OBS SRPM package
- Mandriva GNU/Linux 2008 2.6.27.21-0.1-xen (amd64 gcc4.2.2-0.RC.1mdv2008.0) by build26 buildd via OBS SRPM package
- Mandriva GNU/Linux 2009 2.6.27.21-0.1-xen (i386 gcc4.3.2) by build16 buildd via OBS SRPM package
- Mandriva GNU/Linux 2009 2.6.27.21-0.1-xen (amd64 gcc4.3.2) by build20 buildd via OBS SRPM package
- Red Hat GNU/Linux RHEL 4 2.6.27.21-0.1-xen (i386 gcc3.4.6-9) by build20 buildd via OBS SRPM package
- Red Hat GNU/Linux RHEL 4 2.6.27.21-0.1-xen (amd64 gcc3.4.6-9) by build26 buildd via OBS SRPM package
- Red Hat GNU/Linux RHEL 5 2.6.27.21-0.1-xen (i386 gcc4.1.2-14) by build11 buildd via OBS SRPM package
- Red Hat GNU/Linux RHEL 5 2.6.27.21-0.1-xen (amd64 gcc4.1.2-14) by build26 buildd via OBS SRPM package
- SLES GNU/Linux 10 2.6.27.21-0.1-xen (i386 gcc4.1.2-20070115) by build24 buildd via OBS SRPM package
- SLES GNU/Linux 10 2.6.27.21-0.1-xen (amd64 gcc4.1.2-20070115) by build14 buildd via OBS SRPM package
Older Versions
- – tests by the project, using Build.sh –
- MirOS #7-stable (sparc gcc2.95.3-078E)
- MirOS #10-current (i386 pcc20081028)
- FreeBSD 6.2-RELEASE (i386 gcc3.4.6-20060305)
- MidnightBSD 0.2.1-RELEASE-p2 (i386 pcc20081028-MirPorts-0)
- NetBSD 3.0_STABLE (i386 gcc3.3.3_nb3_20040520)
- OpenBSD 4.3 GENERIC#207 (zaurus gcc3.3.5)
- AIX 5.3 (powerpc gcc4.0.0_powerpc-ibm-aix5.1.0.0, LD 1.65 04/06/2005)
- AIX 5.3 32-bit (powerpc xlC9.0 070428, LD 1.65 04/06/2005)
- AIX 5.3 64-bit (powerpc xlC9.0 070428, LD 1.65 04/06/2005)
- Mac OSX Leopard 10.5.5 (9F33) Darwin 9.5.0 (amd64 gcc4.0.1-Apple_5484)
- Mac OSX Leopard 10.5.5 (9F33) Darwin 9.5.0 (i386 llvmgcc4.2.1-Apple_5555-LLVM_2039)
- Mac OSX Leopard 10.5.4 (9E17) Darwin 9.4.0 (i386 gcc4.0.1-Apple_5480)
- Mac OSX Leopard 10.5.4 (9E17) Darwin 9.4.0 (i386 gcc4.2.1-Apple_5558)
- Mac OSX Leopard Server 10.5.4 (9E17) Darwin 9.4.0 (macppc gcc3.3-20030304-Apple_1823)
- Mac OSX Leopard Server 10.5.4 (9E17) Darwin 9.4.0 (macppc gcc4.0.1-Apple_5465)
- Mac OSX Leopard Server 10.5.4 (9E17) Darwin 9.4.0 (macppc cross-llvmgcc4.2.1-Apple_5555-LLVM_2039)
- Max OSX iPhoneOS 2.0 (N82AP) Darwin 9.3.1 (arm cross-gcc4.0.1-Apple_5484 Apple SDK)
- Max OSX iPhoneOS 2.0 (N82AP) Darwin 9.3.1 (arm llvmgcc4.2.1-Apple_5555 Saurik iphone-gcc 4.2-20080604-1-8)
- QNX 6.3.2 2006/03/16-14:19:50EST (i386 gcc2.95.3)
- – tests by third parties (Build.sh) –
- AIX 5.2 (powerpc xlC7.0) by Jupp Söntgen
- SGI IRIX64 6.5 (mips:R10K mipspro7.4.4m) by Elias Pipping
- SGI IRIX64 6.5 (mips:R10K gcc3.4.1) by Elias Pipping
- Zenwalk GNU/Linux 2.6.25.4 (i386 gcc4.2.3) by Olivier Duchateau
- – even older versions –
- See the old-mksh site
- MidnightBSD (amd64, sparc64) gcc
- HP-UX 11i (hppa, IA64) gcc, aCC
- Interix 3.5 (i386 win2k), 6 (i386 Vista) gcc, msc
- UWIN-NT (i386) dmc, msc
- GNU/Linux (alpha, amd64, i386, macppc, s390) gcc, TenDRA, icc, llvm-gcc4.2, dietlibc, glibc, µClibc
Known to FAIL Build or Test
- UWIN-NT 4.1.0/5.0 2195 2006-02-14 (i386 bcpp BCC32.EXE 5.5.1, ILINK32.EXE 5.00) does not really work except a few basic commands
- Fabrice Bellard’s tcc in combination with GNU libc often fails linking
with an error message like this:
/usr/lib/libc_nonshared.a: '__i686.get_pc_thunk.bx' defined twice (eg. Debian lenny tcc0.9.24-1) - klibc (klcc) on GNU/Linux needs a few patches to work
- mksh works on Plan 9, but does not return after executing a non-builtin command. Syllable Desktop exhibits the same behaviour.
Recommendations on version numbering
mksh by default uses a version numbering scheme that uses full integers, prefixed by a capital letter R significing “Release”. If minor updates are required or requested, a lower-case letter from the standard latin alphabet will be appended, starting at ‘b’ and ending at ‘z’ (but usually way before or at ‘i’). If a packaging system cannot handle version numbers such as mksh-R29b (source) → mksh-R29b-1, mksh-R29bp1 (binary), packagers OUGHT TO map this to a numerical system as follows: mksh-29.2-1, mksh-29.2.1, mksh-29.2nb0, depending on the packaging-system local policy for build numbers / patchlevels.
Schemes to AVOID are mirbsdksh-1.29b, mksh-2.9.2, or worse. Please adhere to our recommendations so that users are able to locate mksh in their operation environment of choice.
/bin/ed
While we’re at it – recommendations for packagers – there is another set of do’s and dont’s: location of the UNIX® standard text editor. As outlined in traditional unixoid operating system standards, manifested into POSIX, and – for these three-letter words that aren’t Unix, no matter which of the kernels they use in their variety of so-called distributions – the FHS (FSSTND): ed lives in /bin/ed, period.
Patching mksh’s code to look for ed in ANY other location is a MUST NOT.
Future Plans
- bash-style multiline command line editing, as an option (the current horizontally scrolled one is finally (with R28) bug-free even with multiline and very long prompts optionally with embedded newlines, and more suitable for small terminals)
- Ensure arithmetics are properly bound to mksh_ari_t and mksh_uari_t and offer switching to 64 bit, including as array index type, as a compile time option; seeing as some systems (DEC?) may not have a 64 bit type
- Adding goto and label keywords/commands
- Adding builtins fstat, lstat, traverse, …
- for a b in …; do (like make(1) does)
- ${foo:S/bar/baz/g} and maybe ${foo:C/bar/baz/x} via regex(3)
- A sensible website
- Build and actually work on more platforms – DJGPP, PW32, Plan 9, Syllable – debug these
- Mode for no input line editing at all (required for Plan 9) and no Emacs just Vi mode (requested by unknown at FOSDEM 2009 – yuck)
- Real Unicode command line editing code
- Real Unicode internal op – ${foo:2:3} now works with MirOS OPTU-8 but having internal representation being MirOS OPTU-16 would help in the long term
- Build with more platforms’ native tools or other compilers – ACK, kencc, ICC/UWIN, egcs/UWIN, tcc
- Add the ability to handle embedded NUL bytes in strings read,
for example in the hexdump “utility” (regression test)
XXX this might be a bad idea actually, cf. php’s insecurity - Bugfix for suspending a && b chain
- echo diff <(echo 1) <(echo 2)
- ;& and ;;& in case like zsh
- read with timeout like ksh93
- read -e like ksh93
- maybe associative arrays? meh, rather the bloat… naah
- Fix RedHat
BZ#496791 without breaking things like
echo $(typeset -i10 x=16#20; echo $x) echo $(typeset -Uui16 x=16#$(id -u) ) echo $(c=1; d=1 typeset -Uui16 a=36#foo; c=2 typeset -Uui16 b=36 #foo; d=2 echo $a $b $c $d)
etc.
Recent Changes
Changes in the current (unreleased) development version:
- Begin porting mksh to the Plan 9 ANSI’n’POSIX Environment (not finished)
- Port to Syllable (again much improved; support now en par with Plan 9’s, thanks to Anthony Morphett <awmorp@gmail.com> – maybe the rest is a kernel bug?)
- [ahoka] Begin porting to Haiku and, implicitly, BeOS (not finished yet)
- [tg] Shut up a bogus gcc warning during configuration process
- [tg] Spell AT&T consistently in the source code
mksh R38c contains the following fixes:
- [tg] Fix regression tests on OSes insisting on a shebang (Cygwin)
- [Sean Boudreau] QNX 6.4.2 ed(1) is said to have the bugs fixed
- [tg] Build.sh bugfixes: -DMKSH_BINSHREDUCED can also be given without -DMKSH_SMALL; allow HAVE_REALPATH=x and HAVE_REVOKE=x in the environment to re-enable these even if -DMKSH_SMALL disables them by default, like mknod already did
- [tg] -DMKSH_ASSUME_UTF8=0 skips the environment checks, like -DMKSH_ASSUME_UTF8=1, but disables the utf8-mode
- [tg] Apply some more KNF – style(9) – to the source; clean it up and further optimise for small size
- [OpenBSD] Fix segfaults caused by missing check for end of input in the tokeniser on “let --” and other input
- [OpenBSD] Make Vi editing mode ^W behave like Emacs mode’s
- [tg] If no killpg(3) is avaiable, use kill(2) and hope it works
- [tg] -DMKSH_NO_LIMITS skips trying to build the ulimit code
mksh R38b fixes the following problems:
- [André Wösten] Add __NO_EXT_QNX to avoid picking up the wrong waitfor() from <libutil.h> in (while porting to) QNX 6.4
- [tg] Plug memory corruption issue introduced in R38
- [tg] Amend dot.mkshrc with a base64 en-/decoder in shell
- [tg] Import a manpage fix via OpenBSD from Alan R. S. Bueno
mksh R38 comes with these changes and fixes applied:
- [tg] Improve regression test output debugging
- [tg] Fix <libutil.h> prerequisites on MidnightBSD in mirtoconf
- [tg] Mention that RedHat BZ#496791 cannot currently be fixed in the manpage by discouraging use of apostrophes in comments in comsubs; add appropriate (expected-fail) regression tests
- [tg] Sync with OpenBSD ksh (mostly a no-op)
- [James Butler] Add search-history-up and search-history-down keybindings (tcsh-like) to the Emacs command line editing mode
- [tg] Bind new search-history-{up,down} to ANSI PgUp and PgDn keys
- [tg] Document ANSI default keybindings (↑↓←→ Home End Del PgUp PgDn) in the mksh(1) manual page as well
- [tg] Optimise internal UTF-8 handling code for size and reusability
- [tg] Incompatible change: ${foo:1:2} and ${#foo} now operate on characters, not on bytes. Characters are octets (set +U) or (utf8-mode) MirOS OPTU-8 multibyte characters (set -U)
- [tg] Improve regression tests relating to ${foo:1:2} and ${#foo} and let wc=1#x and utf8-mode
- [tg] Use per-file copyright notices, move global text to manpage
- [tg] Expose new MKSH_MIDNIGHTBSD01ASH_COMPAT ifdef; change it to only trigger if FPOSIX (or MKSH_BINSHREDUCED and /bin/sh)
- [tg] Remove already-dead “#if 0” style debugging code
- [tg] Change some code into a more portable fashion, optimise
- [tg] Allow [[ $foo ]] (ksh93 extension) mentioned by pgas
- [tg] Clean up mksh and the contributed arc4random.c for some conversion, enum and other warnings for gcc-snapshot trunk r147610
- [tg] Ensure no function uses more than 768 bytes of stack either
- [tg, wbx] Add extension to make “!string” lines work like in GNU bash
mksh R37c provides these follow-up fixes:
- [tg] Improve præprocessor detection/work in Build.sh
- [tg] Decouple MKSH_CONSERVATIVE_FDS from MKSH_SMALL
- [tg] Enable MKSH_CONSERVATIVE_FDS by default on Minix 3
- [tg] Work around the (in-)famous ACK "const" bug
- [tg] Optimise structure alignment and padding; Closes: #522778
- [tg] Retain LOCPATH (for glibc locale) in check.pl
- [tg] Document, simplify and clean up the code better
- [tg] Use mirbsd.org eMail addresses consistently
mksh R37b comes with the following fixes on top:
- [tg] Clean up build system and dot.mkshrc some more
- [tg] Add getrusage(2) implementation using times(3) if none found
- [tg] Add jobless mode (for Minix 3, Plan 9, …)
- [tg] Detect the Amsterdam Compiler Kit in the build system
- [tg] If no RLIM_INFINITY don’t try to do ulimit
- [tg] Work around gcc4 strict warnings vs. broken system headers
- [tg] Work around systems with mmap(2) but no munmap(2)
- [tg] Fix (disallow) bind key macro recursion (instead of beeping and going into an endless loop), allow multi-line bind key macros (mostly from Alexander Hall), remove dead code (the beeping) and optimise
- [tg] Add (commented out, undesired, standards compliance breaking) compatibility code to MidnightBSD 0.1 /bin/sh for ctriv
- [tg] Clarify the mksh(1) manual page even more
- [tg] Port to Minix 3 + GCC
mksh R37 has major standards compliance improvements:
- [tg] Rename -o utf8-hack to -o utf8-mode
- [tg] Fix spacing mode error (pasto) in the mdoc(7) format manpage
- [tg] Implement $((#…)) unsigned arithmetic calculation, needed for arc4random_uniform(3)-in-korn-shell implementation
- [tg] Really preserve LD_LIBRARY_PATH in check.pl
- [tg] New Build.sh option ‘-combine’ for building mksh(1) at once with “-fwhole-program --combine” (gcc4, llvm-gcc4) if available
- [tg] Always set COLUMNS and LINES trying as hard as we can, using TIOCGWINSZ even if used without FTALKING, and with the sane 80x24 default if the ioctl(2) fails
- [tg] Handle _POSIX_VDISABLE being undefined (e.g. Linux/klibc)
- [tg] <sys/file.h> is only required for flock(2)
- [tg] Fix multi-column output routine for the corner case if the screen is less wide than one output column; 10x Gábor Gergely
- [tg] Fix ${foo/@(%)/\\x} in UTF-8 mode (utf_widthadj for control characters U+0080‥U+009F is slightly broken; this fix shifts the brokenness into the command line editing mode only)
- [tg] Introduce mksh_ari_t and mksh_uari_t internal types to limit arithmetics to 32 bit on all systems; currently depending on the already-used standard int32_t and uint32_t types. Future expansion to 64 bit possible. Document that shell integer variables use this type.
- [tg] The variables PGRP, PPID, RANDOM and USER_ID are now unsigned
- [tg] Fix two off-by-ones breaking PS1 ending with a newline; bug reported by Matthias Diener
- [tg] Just pass through C1 control characters for now
- [tg] Code and internal interfaces cleanup
- [tg] Regression test fixes for Cygwin env(1) being unsorted
- [tg] Replace the memory allocator by something equally simple and homegrown but optimised for use with mksh and free checking
- [tg] Import a couple of minor fixes (e.g. spelling) from oksh
- [tg] Fix problems with "set -e" for real; from oksh, Closes: #518359
- [tg] In "set -o posix" mode, have limited echo(1) to improve standards compliance; the exact feature set is open for discussion, e.g. with pkgsrc® people; for now, only -n as first arg
- [tg] Make test builtin operator precedence consistent; from oksh
- [tg] Revamp and fold and enhance the regression tests
- [tg] Document somewhat surprising behaviour in mksh(1) better; here: [ x -eq y ]; for gps23 from #ksh
- [tg] Reduce memory consumption by allocator simplification
- [tg] Fix bugs spotted by DEC ucode cc (ULTRIX) and gcc 1.42 (BSD/OS)
- [laffer1] Make mksh the default /bin/sh in MidnightBSD

