mksh – old versions
This page lists information about versions of mksh(1) earlier than R40.
Old instructions
Compilation
The build script also honours the following environment variables:
- CC (cc) – the C compiler used
- CFLAGS (-O2 / -xO2) – optimiser and other compiler flags used (set to anything containing a letter or digit to prevent Build.sh from automatically adding optimisation flags)
- CPPFLAGS (no default) – additional cpp(1) flags
- LDFLAGS – 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 DJGPP (not yet) DragonFly FreeBSD GNU (Hurd) GNU/kFreeBSD Haiku 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+)
- Feature selectors:
- USE_PRINTF_BUILTIN=1 – add printf.c to the list of files to be compiled and set a flag so it is used as builtin (R39+)
If CPPFLAGS contain any of the following definitions, the resulting binary will be compiled with a specific flavour:
- -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 sh” 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 (different from all other shells); requires -DMKSH_BINSHREDUCED or “-o sh” (R39b+)
- -DMKSH_NOPWNAM – omit getpwnam(3) calls (~foo/ expansion) in order to not pull in the nsswitch or PAM libraries
- -DMKSH_NO_LIMITS – don’t compile the ulimit code (R38c+)
- -DMKSH_SMALL – build a really small mksh(1), e.g. for embedded systems (see below for details of what this entails)
- -DMKSH_S_NOVI=0 – do not omit the Vi editing mode (R39b+)
- -DMKSH_S_NOVI=1 – omit the Vi command line editing mode (" ")
- -DMKSH_UNEMPLOYED – compile without job control (R37b+)
- -DMKSH_DEFAULT_EXECSHELL – default: "/bin/sh" (R40+)
- -DMKSHRC_PATH – default: "~/.mkshrc" (R40+)
- -DMKSH_DEFAULT_TMPDIR – default: "/tmp" (R40+)
- -DMKSH_CLRTOEOL_STRING – default: "\033[K" (R40+)
- -DMKSH_A4PB – force arc4random_pushb(3) for $RANDOM (R40+)
- -DMKSH_NO_DEPRECATED_WARNING (varies between versions)
- -DMKSH_DONT_EMIT_IDSTRING – for broken OSes (R40+)
- -DMKSH_NOPROSPECTOFWORK – disables more than just job control, to use for tracking down signal handling bugs in Syllable, Plan 9 (R40+)
- -DMKSH_NO_EXTERNAL_CAT – always run cat as builtin, instead of diverting to command cat if called with flags (R40b+)
- -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 (set to x to re-enable),
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).
Defining MKSH_SMALL will disable persistent history (to re-enable, env HAVE_PERSISTENT_HISTORY=x), try to compile with -fno-inline, disable the nice(3) extern; (not overridable) implies traditional/conservative filedescriptor usage, MKSH_NOPWNAM; omits shebang checking in scripts, the Vi command line editing mode (mksh R39b and up can re-enable it by defining -DMKSH_S_NOVI=0), certain verbose error messages, the entire ‘-T’ command line option; replaces inlines with separate functions for size over speed optimisation, etc. (In R39b and up, it disables a whole lot more things than in earlier versions.)
Accepted arguments to Build.sh are:
- -combine – all-in-one build, recommended unless gcc is broken; ignored if $CC does not support “-fwhole-program --combine” (gcc4, R37+) – replaced with “-c combine” from mksh R40
- -llvm[=…] – compile to bytecode; option arguments (or, if none given, ‘-std-compile-opts’) are passed to LLVM opt (mksh R36b and up) – replaced with “-c llvm” from mksh R40
- -valgrind – append -DDEBUG -g3 -fno-builtin which are required to work around gcc/valgrind and clang/scan-build bugs (R39b+) – replaced with “-g” from mksh R40
- -d (R29 and below): build dynamically, don't try to link with -static by default on architectures that support it
- -nd (R29 and below): build statically, always try to link with -static even on systems with nsswitch/PAM
- -q (R35b and below): output almost nothing
- -r (all versions): don't try to build a pre-formatted version of the manual page using nroff(1) if found
These special values in CPPFLAGS are recognised:
- -DMKSH_MIDNIGHTBSD01ASH_COMPAT – parse “--” on the shell command line like MidnightBSD 0.1 /bin/sh (different from all other shells); requires -DMKSH_BINSHREDUCED or “-o posix” (R38+) / “-o sh” (R39b+)
- -DMKSH_BINSHREDUCED – include code to automatically “set -o posix” (mksh R39b+: “set -o sh”) to reduce functionality if called as sh or -sh
- -DMKSH_NOVI – omit the Vi command line editing mode, which is orphaned anyway, yet functional (mksh below R39b)
- -DNO_STRTOD – (printf.c) disable floating point (below R40)
- -DMKSH_AFREE_DEBUG – run with extra alloc/free checking (mksh R36b and below)
- -DMKSH_NEED_MKNOD – if MKSH_SMALL is set, do not omit the mknod(8) builtin functionality from the binary; deprecated, use the environment variable HAVE_MKNOD=[0|1] to determine if this builtin should be compiled in or not instead; has been removed past R31c
The build script also honours the following environment variables:
- CPP ($CC -E -) – the C preprocessor used
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-mode flag. 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. All commands of a pipeline are 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.
Hints and other useful stuff
mksh does not write a history file by default any longer; set the
environent variable HISTFILE in ~/.mkshrc (or the
profile) if you want this. The history file format of mksh (and oksh
and pdksh) differs from that of other shells, so you might want to
use a construct like
case $KSH_VERSION in
*MIRBSD\ KSH*) export HISTFILE=~/.mksh-history ;;
*PD\ KSH*MirOS*) export HISTFILE=~/.oldmksh-history ;;
*PD\ KSH*) export HISTFILE=~/.pdoroksh-history ;;
?*) export HISTFILE=~/.ksh-history ;;
*) export HISTFILE=~/.nonksh-history ;;
esac
to avoid them overwriting each others' history file.
Very old sample: this
OS inclusion:
- Crux GNU/Linux used to have an mksh port contributed by Han Boetes.
For packagers: Upgrades
mksh R39c should fix a bug that could have led to accidental removal of the manpage when building in the source directory. AIX builds no longer uselessly pull in libcrypt.
mksh R39b now has a separate caveat section listing the most relevant user-visible changes, split off this packagers' list. The optional, undesirable, unsupported printf(1) builtin is now documented in the manpage. The chdir builtin is an alias for cd. The realpath builtin is now always provided. MKSH_SMALL removes much more functionality than it used to. MKSH_NOVI=1 is now MKSH_S_NOVI=[0|1]. $RANDOM handling is greatly simplified. There's now both “±o sh” and “±o posix”, and they differ; MKSH_MIDNIGHTBSD01ASH_COMPAT needs the former. New build flags -M, -valgrind. The default on HP-UX on IA64 is no longer to default to building with -mlp64 (gcc) or +DD64 (HP aCC). SUNWcc tries -xipo (but requires the packager to use -xO4 or up manually).
mksh R39 has user-visible changes regarding “set -u” (“set -o nounset”) and alias/function name conflicts regarding whitespace before parenthesēs, as well as a much enhanced dot.mkshrc sample file I urge to install. People using a Makefile to build it may need to regenerate their set of CPPFLAGS used; CPPFLAGS handling in general has improved. There is now a defined but unsupported way to make printf(1) a builtin; this is not tested and adds a huge SLOB of foreign code to the build, lets the shell use stdio and floating point, making it bloated and fragile; if you still want it (hi Md), set USE_PRINTF_BUILTIN=1 and add printf.c from mircvs://src/usr.bin/printf/ to the build.
mksh R38c adds QNX fixes, build system fixes, and the (not recommended) ability to use -DMKSH_ASSUME_UTF8=0 to skip the environment checks for locale (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.
At Freshmeat you can subscribe to get automatically notified (with a summary of changes, not the complete changelog, see below) whenever new releases are put out.
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 R36b stays compatible, no surprises there. The ‘-llvm’ option to Build.sh, however, is new.
mksh R36’s Build.sh script ‘-q’ option is gone. Furthermore,
you must add -DMKSH_BINSHREDUCED to your CPPFLAGS now
if you want mksh to behave more POSIXish if called as sh.
OSF/1 V2.0 is now supported using the native DEC C compiler.
mksh R35b builds on some more platforms and throws less warnings, but the build system is almost unchanged; test.sh now shows the Perl binary used (honours $PERL) and its version.
In mksh R35, setlocale/nl_langinfo have been disabled by default for
some platforms. If we do not assume UTF-8, disabling lets mksh employ
the LANG and LC_* environment variables for codeset
determination. Also, a new builtin is included depending on existence
of the readlink(3) function, disabled by default if MKSH_SMALL. The
“pdksh” check category is no longer persistent. The licence has changed
(the advertising clause was removed). The dot.mkshrc sample
was changed to improve re-use.
There was no R34.
No changes in mksh R33c except for Ultrix support. None in R33d.
In mksh R33b, much more compilers are detected, even if not all of them are supported. The OE (OS and CC/LD) versions are now dumped too. Instead of #error, forced link failures are now used as the mechanism to auto-detect some things in the target environment. Features are now much better detected, and some annoying warnings don’t show up any longer due to this. Less tools are required to build.
Please be reminded that you should run ./test.sh -v inside an environment with /dev/tty available (as device node) and usable (e.g. use script(1) or GNU screen if you’re doing auto-builds detached from controlling terminal). Use -v to see failures.
No surprises in mksh R33 either, but the build system now gives more detailed output on the version actually built, to aid tracking down FTBFSen (build errors) with access to only the build logs. Regression tests now work with Intel’s compiler on SLES too, which requires a custom LD_LIBRARY_PATH formerly stripped by the script.
No surprises in mksh R32, but some ancient systems (AIX, Solaris 11, OSF/1, UWIN) are now better supported.
In mksh R31d, parallel make with ‘-j’ was added (no limitation on number of childs though), this even works with Solaris 8 /bin/sh. The MKSH_NEED_MKNOD define is no longer honoured.
From mksh R31 to R31b, arc4random.c has been upgraded.
From mksh R30 to R31, there are no surprises. The “arc4random.c” file is available from mircvs://contrib/code/Snippets/arc4random.c now, and the new “source” command is not available in posix mode either.
From mksh R29 to R30, the following things should be kept in mind:
The syntax of Build.sh has changed: $CC now defaults to “cc” instead of “gcc”, and the ‘-d’ and ‘-nd’ arguments are gone – if you want to build a statically linked mksh, pass LDSTATIC=-static (gcc+GNU ld, adjust for other OEs) to it. An “arc4random.c” is now automatically included into the build if found in the source directory. The $CPP variable is ignored, $CC -E is used instead, except for tcc, which uses “cpp -D__TINYC__” because “tcc -E” doesn’t work.
As a tribute to better POSIX compatibility, certain aliases (like “stop”) are no longer predefined in “set -o posix” mode, which is invoked automatically if the shell is run as -sh, /bin/sh or similar, so that they can be used as function names.
If defining MKSH_SMALL, the ‘vi’ editing mode is omitted, which may surprise your users.
Many compilers other than gcc are now supported as well as AIX.
Users' Upgrade Caveat
R39c: Evaluation of things like ${foo:-bar} and "${foo+bar}" now behave standards-compliant (SUSv4) and more like all other shells, sans bugs. In particular, if a ${} expression is double-quoted, the apostrophe/single quote loses its special meaning within, whereas it still acts as quote character if the expression is not double quoted. Other special characters' meanings have been updated to match standardised/expected behaviour.
R39b: Due to a lot of bugfixes and some enhancements, take care when upgrading. The realpath builtin is now always available. There are now both “±o sh” and “±o posix”, and they differ (scroll down to almost the end of the R39b changelog). In numeric expressions, “'a'” is an alternative to “1#a” like in ksh93; “$'…'” expanded strings are now also supported. Some constructs parse more loosely, and things like “function stop () {” work now. MKSH_SMALL removes much more functionality than it used to. set +o arc4random is no longer possible (either it's there and used, or it's not). "mksh /tmp/horsies" now exits 127 ipv 1 (ENOENT). 「((foo) || bar)」 and 「((foo) | (bar))」 work now. Lazy evaluation of ternary operations is fixed. In '-o sh' mode, echo does not expand backslashes any more. In '+o sh' mode, “set -- $(false)” POSIXly correctly returns 0 (and breaks getopt(1) in traditional usage mode). Changes of variables inside Bourne style functions affect the caller's environment. “eval $(false)” also returns 0. “±U” is now honoured on an interactive shell's command line. Finally, the getopts builtin now behaves standards-compliant: even on an unknown option, OPTIND is incremented (think “getopts "ab:c" ch” and “script -a -I foo bar” in contrast to “script -a -- -I foo bar” – mkdep(1) was affected, as will be every script that does not abort in the (\?) or (*) case).
mksh R39 has user-visible changes regarding “set -u” (“set -o nounset”) and alias/function name conflicts regarding whitespace before parenthesēs.
Recent Changes
mksh R39c is an important minor bugfix release:
- [tg] Build system, code, docs and testsuite cleanup, also style(9)
- [tg] Build.sh now requires people to whitelist conftest*.c
- [tg] AIX builds no longer pull in libcrypt uselessly by default
- [tg] Parse and evaluate ${parameter op word} correctly
- [tg] Fix possible SIGSEGV in interactive mode bind builtin due to mis-optimisation of gcc combined with a bogus prototype; discovered by Grml.org's Frank Terbeck (ft), thanks!
- [tg] Prevent Build.sh from accidentally removing mksh.1
mksh R39b is a major stability and bugfix update:
- [tg] Clean up some more strict *roff or compiler warnings: dashes, undefined macros; casting errors (constness, signedness, type width/class) and catch possibly unaligned pointer dereferences early; remove code/rodata redundancies, plug memory leaks
- [smultron] Tweak the manual page: point out the word “colour”
- [tg] Optimise dot.mkshrc DJB’s CDB hash implementations; add Bob Jenkins’ one-at-a-time hash (standard and leading-bit initialised); fix signedness in expressions; let the hashes use stdin if "$*" is empty, like Lb64{en,de}code; use “[[ -o utf8-mode ]]” ipv “[[ $- = *U* ]]”
- [tg] Build.sh portability fixes: missing prerequisite headers; ensure $CC is never called without $CFLAGS; fix test.sh, et al.
- [tg] Optimise internal variable representation; use one-at-a-time hash; cache hash values for faster resizing at zero memory cost; clean up hash table (keytab) code; switch hash table collision resolution algorithm to Python’s; prepare for later changes (commented out)
- [tg] Fix type errors in the source code (int → bool, size_t, mksh_uari_t)
- [tg] Fix “${foo:bar:$baz}” not working (missing substitute() call)
- [tg] Implement “typeset ±a” as nop
- [tg] Support ksh93-like “${!foo[@]}” listing the keys (indicēs) of all set array elements – zsh does it too (${(k)foo}), bash4 can’t :þ
- [tg] Support bash/ksh93-like “array=([key]=value …)” and (additionally) “set ±A array -- [key]=value …” to directly specify indicēs to use
- [tg] Document the optional, unsupported, printf(1) builtin in TFM
- [tg] Replace realpath(3) dependency and internally used get_phys_path() pdksh code with own implementation; always offer the realpath builtin
- [tg] Implement nameref='typeset -n' (bounded variables) like AT&T ksh93 but with mksh-style nested/dynamic scoping and on-use resolving; they cannot currently be stored in an array though
- [tg] Add “chdir” builtin doing the same as the “cd” special builtin
- [tg, David Korn] Document more differences between mksh (and pdksh) and AT&T ksh (or, more specific, ksh88, ksh93) in the manual page
- [tg] Support “'a'” as an alternative to “1#a”, like ksh93 does
- [tg] Add ksh’s “test -o ?foo”: true if “foo” is a valid shell option, where “foo” can be “xtrace” or “-x” or “+x” (these three are equivalent)
- [tg] Support “$'…'” backslash-expanding single-quoted strings, as requested by David G. Korn, with almost the same syntax and semantics
- [tg] Unify backslash expansion code (C style vs. print builtin mode)
- [tg] Support “function stop () {” bashism
- [tg] For several items in the source code that require order to be kept, provide it from multiply-included header files; sort correctly
- [tg] Get rid of unneeded FMONITOR (-m) for shells without job control; sync list of flags, comments and manpage with reality
- [tg] If MKSH_SMALL, reduce size by removing editor functionality
- [tg] Support VT100 emulator style {Ctrl,Alt}-CurLeft/Right keycode sequences with new vt100-hack emacs bind function (LP: #355883)
- [cnuke, tg] Remove more, like GNU bash extensions, from MKSH_SMALL
- [tg] Remove more functionality, such as Emacs command line editing mode bind key macros, and other extensions, from MKSH_SMALL to help floppies
- [tg] Make forking and subshells less expensive wrt. random state
- [tg] Build and source code fixes for / caught by SUNWcc, HP aCC, pcc, DEC ucode cc (MIPS), GCC, LLVM clang
- [tg] Make undef/def MKSH_NOVI into 0/1 MKSH_S_NOVI build flag
- [tg] Get rid of "U getenv" in nm(1) output, we already import environ
- [tg] Simplify $RANDOM handling: reads are now either arc4random(3) (if available: set +o arc4random is no longer possible) or an LCG; writes are arc4random_pushb(3) if available for explicit writes, arc4random_addrandom(3) otherwise, or another one-at-a-time hash feeding the LCG; furthermore, RANDOM is now always exported to and imported from (implicit read: no push to kernel done) the environment vector on startup and spawning
- [tg] Internal code cleanup, optimisation, moves to different files; dead/commented out code removal; code beautification
- [tg] Document mksh does not exactly use OPTU-8/OPTU-16 in the manpage, as well as when characters, octets, or screen columns are used
- [tg] Fix exit 127 on "mksh /tmp/horsies" ipv of 1 on ENOENT, #548744
- [Clint Adams] Fix typos in the testsuite
- [tg, Clint Adams] Begin a shared testsuite for mksh and posh
- [tg] Make 「((foo) || bar)」 and 「((foo) | (bar))」 work
- [tg] Fix lazy evaluation of assignments by ternary operator, #445651
- [tg] Work around Cygwin bugs (quirks) hindering the testsuite
- [tg] In FSH mode, “echo [-n] 'foo\x40bar'” shall not be expanded
- [tg] Let Build.sh run with AIX bsh (SVR3 Bourne Shell)
- [tg] Let set -- $(false); echo $? return 0 (POSIXly correct) in FSH mode, 1 (needed for getopt(1) support) otherwise
- [tg] Changes of variables inside Bourne style POSIX functions indeed affect the current execution environment (of the function caller)
- [tg] Fix getopts behaviour (sync with AT&T ksh93 not ksh88)
- [tg] “eval $(false)” shall return 0 (Debian Closes: #550717)
- [tg] Ensure that /* apo'strophes in comments */ work
- [tg] New Build.sh flag -M to not compile but spit out a Makefrag.inc file from the current build environment, such as the (cross)compiler, CFLAGS, LDFLAGS, etc. which then can be sourced by e.g. the Android NDK, or built with make(1) – BSD make and GNU make have been tested, but almost all makes should work if the source and build directories are the same or VPATH is supported at least (use of this option is discouraged)
- [tg] Overhaul and simplify handling of (special) variables
- [tg] Further reduce memory (code/data) and import footprint
- [tg] Use functions without PATH_MAX limit on GNU/Hurd
- [tg] Fix tab completing pathnames containing ‘:’, ‘=’, ‘$’ or ‘`’
- [tg] Support ‘-T <tty>’ even if MKSH_SMALL and fix it
- [tg] Remove "which" alias "whence -p" to allow "which -a" in dot.mkshrc and add more examples, some commented out
- [tg] Fix print_columns() issue with displaying items where characters had differing number of octets and columns, and the off-by-one which had hidden this problem with 2-octet 1-column and 3-octet 2-column chars
- [tg] Beautify the manpage in both AT&T nroff and GNU groff
- [tg] Fix null-expansion of “${x%?}” if $x is unset
- [tg] Make some globbing (${x%?}) operate on characters instead of octets; update manual page to reflect that others still do and remove wording that let people think we’d ever support POSuX character classes
- [tg] New ${%foo} returning width of $foo in screen columns, or -1 if $foo contains an ASCII/latin1/Unicode C0/C1 control character
- [tg] Fix subtle possible portability problem wrt. CHILD_MAX
- [tg] Honour ±U on command line of an interactive shell
- [tg] Fix dead stores and other bugs pointed out by the Clang static analyser; put assertions in places it has false positives (-DDEBUG)
- [tg] Plug uninitialised memory access and possible out-of-bounds read of a buffer caught by Valgrind; change one memcpy(3) to memmove(3) where srcbuf and dstbuf overlap; place (-DDEBUG) workaround for false positive
- [tg] HP aCC: change IA64 default from forced +DD64 to using the default; support Bundled compiler; fix double-const warning
- [tg] Rework __attribute__ compiler capability check
- [tg] Apply errno save/restore related fix from (sync with) oksh
- [tg] Build.sh: output message when switching from autoconfiguration to building / output generation (requested by Matt “lewellyn” Lewandowsky); use “conftest.c” ipv “scn.c” (to please ccache); check for “-xipo” with SUNWcc (suggested by lewellyn as well)
- [tg] Allow “unset foo[*]” (keep attributes) and “typeset foo[*]” (for forward-compatibility; in R39b it’s the same as “typeset foo”)
- [tg] When persistent history is enabled (but not MKSH_SMALL) and used, intertwine the shells concurrently accessing $HISTFILE better ⇒ sync on empty or duplicate line as well (requested by Maximilian “mxey” Gaß)
- [tg] Split off “set ±o posix” and “set ±o sh” again, to be somewhat
more compatible to various old or vendor versions of pdksh and mksh:
- MKSH_BINSHREDUCED sets FSH but not FPOSIX
- MKSH_MIDNIGHTBSD01ASH_COMPAT depends on FSH but not FPOSIX
- The echo built-in behaves the same for FPOSIX and FSH
- File descriptors > 2 are not closed for both FPOSIX and FSH
- Both “set -o posix” and “set -o sh” call “set +o braceexpand”
- In contrast to R39 and below, the errorlevel of “set -- $(getopt ab:c "$@")” is now the same in ksh and FPOSIX mode (0) and only FSH will use the errorlevel of getopt (used to be the other way round)
- [tg] Document some more shortcomings in the mksh(1) manual page
- Contributed printf.c fixes:
- [tg] Make printf(1) builtin use “$'…'” mode, like ksh93
- [tg] Fix const-cleanliness
- Contributed arc4random.c fixes:
- [tg] Fix buffer overflows in the Win32 codepath of the contributed arc4random.c file and limit the rate of expensive CryptGenRandom calls if we have other (seed in registry key) entropy pools
- [tg] Fix uninitialised memory access caught by Valgrind
- [tg] New Build.sh flag -valgrind since I’m lazy
mksh R39 evolved into these through various means:
- [tg] Shut up a bogus gcc warning during configuration process
- [tg] Spell AT&T consistently in the source code
- [tg] Tweak mksh(1) manual page, from wbx@ and «lewellyn:#ksh»
- [tg] dot.mkshrc: fix $@ vs. $* mix-up
- [tg] dot.mkshrc: add DJB cdb hash function
- [tg] Sync with oksh: fix Vi editing mode word erase handling, again
- [tg] Skip whitespace between POSIX style shell function name and its definition parenthesēs during detection if an alias of the same name already exists to be more robust (Debian Closes: #535970)
- [tg] Build system improvements for ACK and nwcc, both on Debian sid
- [tg] Fix spelling error in changelog discovered by Lintian
- [tg] Aligh “set -o nounset” / “set -u” behaviour with future POSIX standard, as discussed with GNU bash maintainers, David Korn from AT&T ksh93, and The Open Group; prompted by use in Debian; Closes: #539538
- [tg] add an unsupported way to make printf(1) a builtin
- [tg] Build system and regression test code and comment improvements: better and more comments matching reality better; more reliability w.r.t. passed CPPFLAGS; more of the MKSH_SMALL changes may be overridden, all of them are now enumerated on the webpage; fixed some breakage; portability
- [tg] MKSH_NOPWNAM and MKSH_SMALL will now both disable the ~fac/ (homedir) expansion code wholly if defined, not just getpwnam(3) calls
- [tg] shells without job control no longer define the standard “stop” and “suspend” aliases (they are pointless anyway); regression tests know
- [tg] use system RCS ID macros on MirBSD if decent enough
- [tg] shut up bogus gcc 4.5/trunk warnings caused by over-optimisation
- [tg] restore ANSI C compilability broken in R38 (speed up, even)
- [tg] use memcpy(3) ipv strlcpy(3) if possible and safe and secure
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 available, 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
mksh R36b is a compatible, major bug-fix update:
- [tg] Add check for naming the output file “scn” instead of “a.out” or “a.exe” when compiling scn.c, for Haiku, from Adam “replaced” Hoka
- [tg] Rewrite utf_backch macro and x_bs2 function into a combined x_bs3 function for the Emacs editing mode, to optimise them and get rid of the use of __typeof__ (suggested by Anders “ragge” Magnusson after the problem was spot by replaced) and one of the uses of the statements-as-expressions feature
- [ahoka] Add mirtoconf check for nice(3), missing on Haiku
- [tg] Remove all uses of the statements-as-expressions feature by rewriting the source code accordingly and optimising some parts
- [tg] Recognise nwcc (Nils Weller’s C compiler) in Build.sh
- [tg] If <strings.h> exists, pull it in for strcasecmp(3)
- [tg] Welcome QNX/Neutrino; work around broken /bin/ed
- [tg] Simplify, shorten, speed up PS1 in dot.mkshrc
- [tg] Remove some dead code courtesy of scan-build native runs
- [tg] Add some casts to prevent LLVM+Clang warnings
- [tg] Work around llvm-gcc-4.2.1 -Wformat pickyness
- [tg] Add new Build.sh option ‘-llvm’ (clang, llvm-gcc)
- [tg] Speed up mirtoconf if ‘-DMKSH_ASSUME_UTF8’ is set
- [tg] Add the workaround for Debian #492377 into the main mirtoconf function (hiding gcc errors during the configure phase) because Gentoo has similar scanner issues; reported by Hanno Böck
- [tg] If an MKSH_SMALL has arc4random(3), skip the rand(3)/srand(3) fall-back altogether to shrink size, also removed need for time(3)
- [tg] Fix alias expansion recursion check if the word to be expanded is immediately followed by end of input, add test case; spotted by Michael Hlavinka in pdksh and mksh; RedHat #474115
- [tg] Fix string/wdstring confusion preventing bashiop (&>foo) to work inside a function, add regression test, limit to 99 fds
- [tg] change regression tests to set -U or set +U instead of set -o utf8-{hack,mode}, as well as query using $- ipv $(set +o) (easier and more reliable)
- [tg] Add comment to regression tests which can fail on slow machines or Cygwin environments due to timing issues
- [tg] Remove a lot of superfluous casts, improve type cleanliness
- [tg] Insert a couple of /* CONSTCOND */ for lint
mksh R36 features the following changes:
- Fix Build.sh invocation without ‘-r’, 10x Elias Pipping
- Mention the MirOS OPTU-8 and MirOS OPTU-16 encodings in the manual page, now that we have a name for it
- In the MirOS base installation via Makefile (and not via Build.sh, run with -DMKSH_AFREE_DEBUG (unless ramdisc or MirOS-stable or formal release, i.e. DEBUGLIBS is not set)
- Merge final version of jaredy’s fix for the stack-storage free issue
- Be more efficient in the mksh(1) manual page example section
- Fix multi-line $PS1 in the (officially orphaned and unsupported) “vi” command-line editing mode (regression; reported by asarch via IRC)
- Fix multi-line $PS1 where the last line is too long for the edit area to fit on the screen, genuine (pdksh, probably) bug, while here
- Plug a memory leak; patch from jaredy taken via oksh
- Fix mis-information re. -o posix mode in the manual page
- If -o posix is set, do not keep file descriptors created via I/O redirection, as Korn Shells do, private; add regression test; Debian Closes: #499139; reported by Markus Schaber and Agustin Martin Domingo
- Work around GNU getopt(3) violating every single standard in existence regarding flag placement on the command line (test suite), from Debian
- Sync internal wcwidth(3) implementation with Markus Kuhn’s latest
- Optimise internal multibyte⇐⇒wide character conversion functions
- Emacs editing mode: if the input line is modified (after a history search) or newly typed or empty, preserve it when scrolling the history, requested by many (at least: gecko2, Matthias Diener, Benny, myself)
- Do not push lines beginning with an IFS character or IFS white space into the history (at the PS1 prompt only), for Matthias Diener
- Emacs editing mode: if an Escape character ends a history search, and Escape is bound to prefix-1, and the following character in prefix-1 mode is a prefix-1 or prefix-2 key, do not swallow the Escape character
- Emacs editing mode: new command “edit-line”, bound to ^Xe by default like in lynx(1), allows for interactive editing of the current input line similar to Vi mode “v” command, requested by asarch in IRC
- Build.sh: remove the problematic ‘-q’ option
- Fix internal type abuse: convert more int to bool
- Ignore duplicates when pushing interactive lines into the history, prodded by Matthias Diener, wanted by myself for quite a while
- Ignore duplicates after fc -s editing too, fix regress test
- <libutil.h> needs <sys/types.h> on some platforms
- Implement somewhat different behaviour for repeated invocations of the Emacs prev-hist-word editing command, so that even a single invocation trashes “the mark”, but repeated invocations scroll up the history, similar to what GNU bash attempts and zsh does, by request of Han Boetes
- Improve support for AIX 5.2 / xlC V7.0, from Jupp “cnuke” Söntgen, which does not respect cc -qversion or ld -V (new for improved version reporting on AIX 5.3 / xlC V9.0), but also errors out if a static bounds checker on arrays is triggered by pointer assignment (such as p = arr[sizeof (arr)];, even if the only accesses are of the *--p style, by preventing it from recognising static storage in this case
- Neither AIX has a UTF-8 locale, so disable use of setlocale(3) there
- Fix some of the things the LLVM-Clang scan-build static analyser spotted and a couple of compile time warnings
- Reduce amout of stack space eaten, prefer .bss storage
- Restore old input line on history search abortion
- (unrelated) update arc4random.c sample to allow use of arc4random_pushb(3) on GNU/Cygwin by using Microsoft® CryptoAPI
- Bring back automatic -o posix setting if the shell is invoked as “sh” or “-sh” (unless compiled with MKSH_SMALL), add regression test, change it to be only compiled in with -DMKSH_BINSHREDUCED
- Improve mksh(1) manual page
- Add support for Digital UNIX (DEC OSF/1) V2.0 (MIPS) with DEC C and ucode ld, work around a bug by conditionally using static linking
- Change Build.sh slightly to accomodate for “true Bourne shells” such as OSF/1 V2.0’s /bin/sh in printf(1) detection
- Improve OS / compiler / linker version reporting
- Optimise the code and Build.sh slightly
- (unrelated) fix arc4random.c sample missing defns
- Use the Unicode MirOS Licence template proper in copyright
mksh R35b comes with the following bug fixes:
- IRIX also has no UTF-8 locale at all, confirmed by Elias Pipping
- Fix regression test suite for MKSH_SMALL
- Bring in latest changes from oksh (OpenBSD ksh, not DeliLinux crap)
- Fix abuse and unsafe use of str_save() and str_nsave()
- Optimise the implementations of str_save() and str_nsave()
- If MKSH_AFREE_DEBUG is defined, guard against afree()ing a pointer which has not been allocated from the given pool, from Todd C. Miller
- Fix attempt to free a pointer to stack (function-local) storage when redefining a function containing a call to the “time” built-in, discovered by Elias Pipping, patch by Jared Yanovich, help from Todd C. Miller
- Protect a little against people not running “./test.sh -v” but calling it with, for instance, GNU bash (as homsn did…)
- Honour $PERL environment variable in test.sh, improve scanning for Perl, do not use potentially undefined $^O, print Perl version
- Add <sys/types.h> as <ulimit.h> requirement (dietlibc)
- Work around bug in BSD/OS 3.1 /bin/ksh (PD KSH v5.2.8 96/08/19)
- Add regression tests from OpenBSD’s <bsd.regress.mk> suite
- Use better CPPFLAGS for AIX, Minix 3 (from pdksh)
- Expose the “s ≠ NULL” str_[n]save_() API and use it where the string can never be NULL (local stack storage), from gcc-4.2 warnings
- Clean up pointer-to-integer-cast warnings in the mirtoconf process
mksh R35 comes with helluva changes:
- Simplify and refactor the ulimit builtin, partially from oksh
- Some style cleanup; use appropriate integer types
- Fix a bug in table (e.g. kill -l, tab completion) display: the width of non-ASCII characters is now honoured in the utf8-hack mode
- Improve handling of invalid UTF-8 in certain areas, and multibyte (UTF-8 / CESU-8) in general
- When using “typeset -Z«n»” on an integer variable with a base other than ten, zero-pad the value instead of the base – pdksh, oksh, zsh, and AT&T ksh93 are wrong here; GNU bash doesn’t even have typeset
- Improve parsing of “set +o” output where done (dot.mkshrc, check.t)
- Improve regression tests
- Support for base-1 numbers: in non-utf8-hack mode, ‘1#x’ means the same as the ASCII code for ‘x’ (e.g. 78hex), where ‘x’ is any single octet (byte); in utf8-hack mode, ‘x’ is either a valid and minimalistically encoded UTF-8 multibyte character in the range 0000‥FFFD, or a single octet with no trailing octets (bytes), which will then be converted as if it were an ASCII value, or, if bit7 is set, be mapped into the PUA range of EF80‥EFFF assigned by CSUR for this purpose; this mapping is, in both cases, bidirectional; the planned base-0 number support is not possible with the code, so use base-1 (with utf8-hack disabled, or & 0xFF) instead (while it is recommended to parse only single octets, there is a regression test showing correct and safe multibyte parsing, which however is error-prone to implement and thusly not recommended) – “genial” replaced@TNG, “this sounds fun” ggergely, agreed bsiegert@ and others
- Pull in more current versions of supplied files; use Unicode 5.0
- Clean up unused definitions in build system; document MKSH_CLS_STRING
- Remove advertising clause from copyright file; while we’d be pleased to be mentioned if something contains our code, tg@ will no longer enforce the requirement to advertise with that specific formula, and we’d prefer if people remember the OpenHAL vs ath5k incident and that they cannot simply change licencing of existing code; patches sent to the MirOS Project for inclusion shall be accepted if they’re agreed to match this licence
- Simplify dot.mkshrc sample file: licence is merged into the main copyright file; AT&T ksh93 compatibility was improved
- Fix a display problem regarding fullwidth characters (e.g. CJK)
- Set the “C” locale in Build.sh for tool execution; otherwise, certain OEs behave strange; thanks to Adam “replaced” Hoka for spotting
- Use en_US.utf8 as UTF-8 locale for the testsuite for now
- If setlocale(LC_CTYPE, "") is not available, look at the environment variables ourselves – brings UTF-8 support to poor OSes
- Remove some now-dead code; speed up configuration process; shrink
- Default to no setlocale(3) due to stubbed or missing locale support on GNU/Cygwin, OpenBSD, OSF/1 in Build.sh; a few more that are quite unlikely to have a UTF-8 locale: BSD/OS, Interix, Minix, PW32, Ultrix, AT&T UWIN; default to always UTF-8 on Plan 9
- Fix for testsuite unexpected failure if running as root in one case
- Initialise all shell integer variables (OPTIND, PPID, RANDOM, SECONDS, TMOUT) to base 10
- Reintroduce from mksh pre-R24 shell integer variable PGRP set to the PID of the process group leader via getpgrp(2)
- New shell integer variable USER_ID set to the geteuid(2) and used by dot.mkshrc to speed up logins, saves a spawn of id(1), mentioned by and realisation planned with Andreas "gecko2" Gockel
- Fix dot.mkshrc tilde replacement in both $PS1 and the pushd/popd/dirs implementation when the home directory is empty, the root directory, or ends with a slash (disable replacement in that case)
- Support dietlibc, force it into providing a BSDish caddr_t
- Do not use LDFLAGS and LIBS while compiling with -c
- Add realpath(3) builtin, to further speed up logins and chdirs
- Optimise the code somewhat by making use of possible assumptions
- Set the “C” locale in test.sh as well to quell warnings
- Split the regression tests that use locale between en_US.utf8 and en_US.UTF-8, since not all OSes support either one, and make only HP-UX and GNU use the latter
- Fix kill, mknod(8) builtin usage msg, from Igor Sobrado via oksh
- Use proper ptrdiff_t casts for pointer arithmetics, inspired by an oksh commit from Federico Schwindt
- Remove check category “pdksh” from check.t and test script
- Improve Darwin, OSF/1, HP aCC, SUNpro version reporting
- Support GNU bash “&>” extension, even better than they do, suggested by Lukas “smultron” from MidnightBSD
- Basic support for LLVM+clang in the build system with experimental “ccc” compiler driver; llvm-gcc worked as-is before already
- Better support for contributed arc4random.c file
- Do not spin if unlink(2) fails on $HISTFILE, from Decklin Foster
- Dump the perl(1) $^O variable in test.sh to logs
- Pull in latest changes from oksh
- Allow white space between a here string indicator and the string, accidentally discovered by twkm (#ksh, freenode)
- Allow fd specifications outside the 0‥9 range for I/O redirections, and bounds check them to be lower than the FDBASE definition, currently still 10 if MKSH_SMALL, 24 otherwise (unportable)
- Improve the regression test suite: for one test, we had a bizarre constraint telling it won’t work on UWIN, which was based upon false assumptions, but Tru64 would fail it since its cat(1) unexpectedly outputs some error messages (fix by closing stderr for cat); another test would unexpectedly print no error message on Solaris (fix by making the error message optional in the perlre(1) used)
- Switch back to en_US.UTF-8 for glibc, Debian can do both, Mandriva fails on en_US.utf8 (XXX no libc5 auto-detection to disable it)
mksh R33d is a quick security-update with these changes:
- Move a portability define from sh.h to the setmode.c helper, as it’s only needed there, and we want to use the latter from MirMake as well
- SECURITY: when spawning mksh on a new terminal, for example with sudo mksh -lT/dev/ttyC7, flush all of that tty’s I/O first (CVE-2008-1845)
- dot.mkshrc: ensure “ls” is no alias, don’t hardcode its path
mksh R33c issues fixes for the following issues:
- Handle Ultrix mmap(2) having a different prototype (returning a caddr_t instead of a void * and not defining MAP_FAILED; making Ultrix 4.5 a fully supported platform
- Decrease code size and optimise (using puts-style functions instead of printf-style functions for fixed strings; bool instead of int)
- Correct behaviour of “export”, “export -p”, “readonly”, “readonly -p”, “typeset”, “typeset -p”, “typeset” and their respective descriptions in the manual page; problem reported by Danijel Tasov
- Work around dup2(2) problem (preserving the close-on-exec flag) on Ultrix using code from mirbsdksh-1.11, lost in oksh
- Clean up Build.sh a little more
- Correct quotes and some other stuff in the regression tests; fix for running with old Perl (5.002 or so, Linux 2.0, BSD/OS)
- Export the new “__progname” and “__perlname” environment variables to the suite run from check.t in check.pl
- Do not mistake IBM xlC and VisualAge for different things, thanks to Pascal “loki” Bleser from OpenSuSE for information on them
mksh R33b comes with the following minor fixes:
- Work on porting 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?)
- Fix some minor code issues remarked by MIPSpro
- Port to SGI IRIX 6.5 (uname: IRIX64) using gcc and MIPSpro
- Scan for a lot more compilers; add support for MIPSpro
- Ignore if the OS doesn’t define MAP_FILE for mmap(2)
- Use sys/types.h as sys/mkdev.h dependency
- Enable OSF/1 V2.0 /bin/sh to run Build.sh
- Add strcasecmp(3) proto for Ultrix 4.5 only (imake style)
- Add S_ISLNK if the OS doesn’t define it
- Use tempnam(3) if mkstemp(3) not found – not recommended
- Reduce dependency on certain OE facilities: printf(1), fgrep(1) being able to scan for two patterns at the same time, perl5 being named perl
- New -T- option for dæmonisation, cf. man page
- Port to BSDi BSD/OS 3.1 (gcc 1.42 and gcc 2.7.2.1 supported)
- Simplify the dot.mkshrc file and make it more robust
- Report OE and $CC version in Build.sh, for logs
- Fix look’n’feel of the mksh(1) manual page, so that it still looks best in AT&T nroff(1), looks much better in GNU groff (the PDF version we place on the website), and looks some better and gains the ability to copy’n’paste from it for GNU gnroff -Tutf8, originally prompted by Patrick “aptituz” Schoenfeld and “lintian -viI mksh*.changes”, but then improved (and nroff hacked) by tg@ a lot
- Shut up some gcc warnings (explicit braces; cast MAP_FAILED)
- Try to get rid of the test “if the compiler fails correctly” by using the errorlevel of the $CC process (except with Microsoft Visual C++ which returns non-zero even on success sometimes), thus supporting DEC C on OSF/1 (and, quite possibly, gcc3 on Mac OSX Leopard)
- If revoke(2) and flock(2) are found, check if they’re declared
- Promote Tru64 to a fully supported operating environment, even though it needs a plethora of _*_SOURCE defines and has SIGMAX instead of NSIG; OSF/1 V4.0 and Tru64 (OSF/1 V5.1) are supported with both gcc and HP/Compaq/DEC C in various versions
- Generalise the workaround for incompatible sig_t across the platforms that need it (currently, OSF/1 and PW32)
- Shut up annoying warning about gcc 2.7.2.3, 2.8.1, 2.95.x not knowing the “-std=gnu99” and “-std=c99” options without setting proper errorlevel
A release with many new features is mksh R33, look yourself:
- Sync with OpenBSD ksh (no real functional changes)
- Enhance the print builtin with two new escape sequences: \xAB parses the next up to two hexadecimal digits AB and outputs a raw octet (byte) whose ordinary value is AB; \uABCD parses up to four hexadecimal digits and outputs the UTF-8 (CESU-8) representation of the unicode codepoint U+ABCD from the BMP (Basic Multilingual Plane), not depending on the locale
- The . (“dot”) command (and its counterpart source) needs an argument (the script to source); from Debian pdksh package
- In the lexer, do not expand aliases if there is an opening parenthesis just after the token (from Debian pdksh). This fixes the namespace issue that caused a POSIX function definition stop() { … } to fail due to “stop” being a built-in Korn shell alias. Now, aliases are removed when a POSIX function with the same name is defined; Korn functions are still different: their definition does not fail, but the alias retains its precendence (unchanged behaviour)
- Accordingly, do not disable built-in aliases in POSIX mode any more
- Since POSIX mode now only turns off braceexpand mode (which can then be turned back on), do not handle being called as -sh or sh specially any longer
- Clean up the source code: make some constants private to the only file using it; optimise; comment some code; improve portability with regards to stupid tools in /usr/bin (or /usr/xpg4/bin) and foreign compilers
- Implement “here strings” (like ksh93 or zsh; GNU bash collapses white
space if the string is not double-quoted): you can now replace print
-r -- "$foo" | command with command <<<"$foo" with
the very same semantics as command <<EOF
$foo
EOF (stripping initial tabs is not possible) - Implement string replacement ${var/pattern/string} (where pattern is an extended glob pattern), like GNU bash; like with the substring accessor (${var: x: y}) mksh implements almost all corner cases (and double slash), but do not handle trimming arrays yet
- Side note: You can now, as a consequence of the two items above, write, for instance, x=${x//foo*bar/baz} instead of the more complicated x=$(sed -e 's/foo.*bar/baz/g' <<<"$x") or the mksh R32 and before idiom x=$(print -r -- "$x" | sed -e 's/foo.*bar/baz/g') – be sure to check $KSH_VERSION first though
- Use the new $Mdocdate$ RCS keyword in the manual page mksh(1) as well; since this is not portable in tmac.doc especially to GNU groff, prepend a seven-liner implementing it to the .Dd macro
- Fix a mistake in using the .Nm macro in the manual page
- Make Build.sh and the generated test.sh more chatty about what they’re doing and what versions (aids debugging build logs)
- Update the dot.mkshrc sample and make it more portable; it requires mksh R33 or above now though due to use of special functions
- Enhance the website, especially the section about official testing: now, the tests are split into tests done by us via Makefile (MirOS only), Build.sh (portably), porting frameworks, with arc4random.c added, tests by others via Build.sh, via packaging frameworks, failed tests; more links
- Note: the “vi” editing mode is code of historical value and, at the moment, unmaintained. It does not benefit from the fixes to the “emacs” editing mode (horizontal scrolling) or new features (bind keys that end their sequence with a tilde; UTF-8 support). Neither is it supported in either editing mode to bind keys that generate a sequence consisting of more than just a prefix (ESC, ^X, or ESC [), another octet and (“emacs” only) an optional tilde (but this might come in the future). This is explicitly mentioned here due to a user inquiry.
Sported by mksh R32 are these changes:
- Make checks for symbol declarations compile checks instead of link checks, as the binding may not succeed due to different symbol types, for instance on AIX, if the declaration does not match
- Widen the range of array indices to [0‥2³²-1], with negative values being mapped into the high-bit31 range for simplicity
- Fix the pipeline-as-coprocess internal error
- Do not require certain integer types to be defined any more
- Optimise the code and reduce its RAM usage
Everyone should upgrade to mksh R31d with fixes for…
- Support pcc (the ragge version of the Portable C Compiler)
- Add pushd/popd/dirs functions (csh) and precmd/chpwd hooks (zsh) to dot.mkshrc which now requires readlink(1) with -f; requested by many (e.g. some Gentoo users; XTaran of symlink.ch)
- Enable colour escapes in dot.mkshrc since almost nobody groks how to do it right from the manual
- Remove -DMKSH_NEED_MKNOD checks from Build.sh, people should use the HAVE_MKNOD environment variable
- Implement parallel make in Build.sh
- Fix another busy-loop spinning problem introduced by an icc warning, thanks to spaetzle@freewrt.org for keeping to bug me to look for it, as it affected GNU/Linux most, followed by Solaris, rarely BSD
- Improve standard integer type detection in Build.sh
- Cleanups in code, build script and manual page
The mksh R31c (Solaris-only) upgrade for cnuke@ was caused by:
- Clean up Build.sh and “test … -o …” doesn’t exist in Bourne
- Detect if the non-standard u_int32_t type, which was unfortunately used by the OpenBSD project in designing the standard arc4random(3) API, is present (which it isn’t on Solaris), and, if not, emulate it using the standard uint32_t (ISO C99) from <stdint.h>, which we fake as needed (if the standard integer types are not present, e.g. on PW32 and OSF/1); change mksh as well as the arc4random.c contribution to not use these non-standard types
- Remove unused types from the faked <stdint.h> file
A quick upgrade, mksh R31b with major bug fixes:
- Fix typo (blsk → bksl) in check.t test naming
- Autoscan for uint32_t, u_int etc. presence
- Fix some memory leaks, mostly by NetBSD® via OpenBSD
- The “unset” builtin always returns zero, even if the variable was already unset, as per SUSv3 (reported by Arkadiusz Miskiewicz via pld-linux → oksh)
- In tab-completion, escape the question mark, reminded by cbiere@netbsd.org, via oksh
- Fix a busy-loop problem, Debian #296446 via oksh
- Fix a few display output problems in the build script
- Shut up some gcc warnings on Fedora; beautify some code
- Support OSF/1 with gcc2.8, thanks to Jupp Schugt
- Fix gcc4 detection of __attribute__() on non-SSP targets
mksh R31 was released as part of MirOS #10 with these news:
- Support the TenDRA compiler (possibly also Ten15, not tried)
- Begin supporting Fabrice Bellard’s Tiny C Compiler (tcc on Debian cannot link due to duplicate symbols in GNU libc, thus unfinished)
- Improve some mirtoconf checks (most notably, mknod(2) and macros)
- Add new emacs editing command “clear-screen” (ESC ^L) as requested by D. Adam Karim <archite@midnightbsd.org>
- Support building for MidnightBSD
- Add new shell alias “source”, semantics like the GNU bash builtin
- Add new shell option “set ±o arc4random”, controlling whether rand(3) or arc4random(3) is used for the $RANDOM value, use arc4random_pushb(3)
- Add new builtin “rename” (just calls rename(2) on its arguments)
- Fix the inofficial OpenBSD port, from D. Adam “Archite” Karim, 10x
- Disable the less(1) history file by default (privacy issues) in the sample dot.mkshrc file; mention other things in etc_profile
- Fix a syntax error in Build.sh checking for TenDRA
A milestone in development: mksh R30 can do this:
- Build on and for Solaris, Linux and MirBSD with Sun’s C compiler
- No longer build a statically linked shell by default; do not try, do not provide any means; user has to use LDFLAGS instead
- Remove some probably dead mirtoconf checks
- Remove commented out -fwhole-program --combine check and still active -fno-tree-vrp bug workaround thing, the latter because the bug seems to only appear for functions that also exist as a builtin (which was declared with the nonnull attribute)
- Fix a long-standing typo, 10x moritz@obsd
- Prefer more common signal names (SIGCHLD) over uncommon ones (SIGCLD)
- Quieten gcc and support SUNpro 5.8 on Solaris 10 on sparc64
- Optimise signal handling and detection; enable compilers whose præprocessor doesn’t have -dD to generate list of signals
- Optimise mirtoconf meta-checks for persistent history etc.
- Fix a bug preventing manual page generation on Solaris
- Add support for the Intel® C Compiler and quieten it a little; fix a few minor buglets (mostly type conversion) its too verbose warnings show, as well as some errno ab-/mis-use
- Remove support for honouring the CPP environment variable; $CC -E - is simply used instead in the places where $CPP was used previously, because that was used in other places already, and to prevent it from behaving differently from the $CC used
- If a file called arc4random.c is lying around in the source directory at mirtoconf time, scan for <sys/sysctl.h> and use the file if arc4random(3) isn’t found otherwise. From Debian.
- If the basename of argv[0] starts with “sh”, activate FPOSIX early, preventing some typical ksh aliases from being defined
- If FPOSIX, don’t pre-define aliases (except integer and local) to benefit operating environments that never heard of the great Korn Shell…
- #if defined(MKSH_SMALL) || defined(MKSH_NOVI) disable the vi editing mode
- Don’t try to execute ELF, a.out, COFF, gzip or MZ binaries
- Can be built on HP-UX (PA-RISC and IA64) with gcc or HP C/aC++
- Support x=(a b c) bash-like array initialisation
- Support ${foo:2:3} bash-like substring expansion
- Many mirtoconf improvements, fixes; speed-up; better portability
- Enable compilation using Microsoft C/C++ Standard Compiler
- Add UWIN build target using various compilers with the cc wrapper
- Fix struct padding mistakes uncovered by the Microsoft compiler
- Fix double initialisation / unused value assignment errors unveiled by Borland C++ Builder 5.5
- Fix superfluous code detected by gcc 4.2
- Fix large file support for OSes that require CPPFLAGS contains -D_FILE_OFFSET_BITS=64 – it was detected but not actually used in the build; thanks to hondza for the problem report!
- Give the lexer a bigger state stack if !MKSH_SMALL
- Prepare for addition of make(1)-style search/replace operations; correct the code for other substitution expansion operations
- Default $CC to cc not gcc, this is no non-unix-ware ☺
- Support AIX with gcc and xlC; clean up code to warning-free
- Prefer well-known signal names to alphabetically earlier ones
- Fix a bug delivering ERR and EXIT pseudo-signals to traps combined with “set -e”, thanks Clint Pachl and Otto Moerbeek for the hint
In mksh R29g we MFCd the following changes:
- Some optimisations from above; no longer execute foreign objects
- Improvements in checking for __attribute__, multi-idstring support, signals, types, arc4random.c; disable -fno-tree-vrp and -fwhole-program --combine; correct large file support (still kludgy but no longer buggy)
Please use mksh R29f because of below modifications:
- Fix detection of function prototypes (data declaractions were ok)
- Fix a regression introduced in R29e regarding the scroll bar
- Recommendation on version numbering changed; suffixes b, c, … match .2, .3, … like alphabetical numbering order
Dedicated to David Ramsey and Coverity, mksh R29e unveils:
- Don't poll in strcasestr(3) if setlocale(3) isn't used
- Remove some redundant or unused functions
- Fix a horizontal scrolling on tabcomplete bug, reported by David Ramsey, thanks a lot!
- Fix the utf8bom-3 regression test on MirBSD-current
- Some workarounds around problems found by Coverity Scan, mostly issues with Scan, but the changes help gcc to optimise better
- Fix a null pointer dereference in error path, mis-use of strchr(3) to search for a NUL byte, and two possible out-of-bounds array accesses, found by Coverity Scan, many thanks!
- Optimise dot.mkshrc further
- Fix a cursor mis-positioning on backspace bug, reported by David Ramsey again, thanks!
- Fix a scrollbar mis-display on delete bug, reported by David Ramsey
- Fix a scrollbar mis-display on insertion bug, discovered while fixing the above bug
- Correct displaying of scrollbar on delete, with help from dramsey
Portability improvements in mksh R29d contain:
- Unbreak testsuite on Mac OSX (whose brain-dead file system does non-standard Unicode decomposing and normalisation on filenames, thus rendering ANOTHER of our tests unusable *sigh*)
- Port to AIX, thanks to Kurt Telep
- Minor fixes for HP-UX, thanks to HP Testdrive Programme
- size optimisation if utf-8 is assumed to be always on
- Do not scan for and use “-fwhole-program --combine” because it's the cause of at least http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=408850 and breakage with FORTIFY_SOURCE on SuSE; thanks to Pascal Bleser (yaloki), Marcus Rückert (darix), Martin Zobel-Helas, Steve Langasek (vorlon) for tracking this bug down in two different places; Closes: Debian #421518
- small manual page fixes
- copy $PATH from Build.sh to test.sh; thanks to a test account on Sun Solaris 11 donated by Julian Wiesener (yofuh) I was able to verify that you want to prefix $PATH with /usr/xpg4/bin because the other tools (/usr/bin, /usr/ccs, et al.) suck major arse…
- Note: the SuSE package in the Buildservice was created by darix (without my knowledge), is maintained by loki now
- Note: the PDF manual page is now PDF 1.3 (Acrobat 4.x) again
Minor bugfixes in mksh R29c – you might want it:
- Regression fix: mksh has some kind of “encoded string” format; use wdcopy() not str_save() to duplicate this; affects formatting of an error message (and below item) only though
- Bugfix: pdksh has an out-of-bounds memory access; the area of code has been touched by OpenBSD developers but the problem not fixed by them; some optimisations turned this (for the error message formatting of the above item) into a memory corruption bug that was only triggering an actual issue on Debian GNU/Linux experimental on IA-64 with some beta version of GNU glibc; add an appropriate bounds check
- Add mirtoconf check for “large file support” needed on some obscure platforms; requested by bsiegert@, idea from GNU autoconf (thanks)
- Add zsh workaround to Build.sh (just to be on the safe side; zsh isn't bourne sh or posix sh compatible, but I didn't find any severe problems with using it to build mksh yet, it's a weird shell though)
- If execve(2) fails with ENOEXEC, try and parse a shebang line ourselves, in case the kernel can do less than we do, unless MKSH_SMALL
- Strip off and ignore an UTF-8 Byte Order Mark (U+FEFF, 0xEF 0xBB 0xBF) at the beginning of input (file, -c option, stdin, interactive, eval) and when processing shebang lines and enable utf8 mode if encountered
- Enhancements to the dot.mkshrc file, whose status (in MirBSD itself) is now upgraded from “sample file for portable mksh to show off to other OSes” to “used as skeleton file in the default installation” – gets us rid of duplicating this stuff in /etc/profile (MirBSD native) a̲n̲d̲ makes sure that users of portable mksh also have the latest goodies
- When doing shebang parsing, accept not only LF and NUL but also CR as markers for end of the (first) line
- If executing fails, tell the user what exactly failed, too
Immediately upgrade to mksh R29b please:
- Bugfix: display UTF-8 control characters (U+0080..U+009F, i.e. everything with a wcwidth(3) of -1) the same as ASCII control characters (U+0001..U+001F), i.e. with a ctrl caret followed by its value XOR U+0040; subsequently treat their width as 2; fix crash (CPU hog in spinning loop) on meta-tab+backspace
- Fix setlocale description in manual page
- in the utf-8 mode, invalid multibytes are now handled more strictly:
- if it's in x_literal() (“quote” / ^V) mode, it's accepted like now
- if it's a mb sequence start, it's rejected with a beep
- if it's a mb continuation, the whole sequence is silently rejected
- remove unused utf_width() macro
- if $CC supports -fstack-protector-all, add it to CFLAGS
- shut up some more gcc 4.1.2 warnings
- if $CC supports -fno-tree-vrp and is subject to the null pointer test optimised away bug, use -fno-tree-vrp to work around it
- in Build.sh, simplify a.out / a.exe (Cygwin) issues
- shrink the manual page to 39 pages sized DIN A4 when built as PS/PDF
- fix a typo in the manual page
Please upgrade to mksh R29 due to the following changes:
- Fix portability of regression tests using fgrep(1), twice
- Fix description of $RANDOM in manual page
- Fix build under OpenSolaris Build 47 (reported in IRC)
- Use easier __RCSID() stuff from MirOS #9-current
- Don't shebang with spaces in test.sh creation
- Remove -fno-strength-reduce from default CFLAGS, the compiler bug was fixed between gcc 2.7.2 and gcc 2.7.2.1…
- Avoid unaligned memory access causing SIGBUS on IA-64 on Debian
- Convert to autoconf-style check for function and header file existence of <sys/param.h>, arc4random(3), arc4random_push(3), setlocale(3) and LC_CTYPE, nl_langinfo(3) and CODESET, getmode(3) and setmode(3), strcasestr(3), and strlcpy(3)
- Add set -o utf8-hack aka mksh -U which changes the Emacs editing mode to an experimental CESU-8 aware multibyte mode (not implemented using wide chars unless internally needed; does not require OS support); check setlocale(LC_CTYPE, "") and nl_langinfo(CODESET) if found to auto-enable utf-8 mode in interactive shells
- Simplify and clean up code; try to remove or replace function calls by smaller equivalents; spot a few non-fatal off-by-one errors
- If Build.sh is called with -DMKSH_SMALL in the CPPFLAGS environment variable, the built-in mknod(8) will not be included, and other functionality and verbose usage messages will be excluded; some macros will be turned into functions to save space and to check if the utf8-hack should be enabled, nl_langinfo(3) is not called. The -T option to mksh(1) and persistent history are not supported.
- Hand-optimise the code to be small, even in the normal build
- Unbreak the -d option to Build.sh
- Check for cc options -Wno-error, -fwhole-program --combine, and (if MKSH_SMALL) -fno-inline and use them if they don't fail
- The autoconf-style (“mirtoconf”) checks have been enhanced, improved and be made more verbose by default
- Rewrite a few functions both to save space and to simplify/unify the code; also spotted a few bugs in existing (inherited) code
- Fix format string mistakes and wrong function and data prototypes
- Correct zero-padding for right-justified strings; add regression test
- EXECSHELL is now ${EXECSHELL:-/bin/sh} again
- Remove duplicate code if feasible; rewrite remaining code to solve all use cases, or use standard library functions such as qsort(3); rework the ctypes and chtypes stuff, get rid of libc/ctype.h
- Change the eaccess() code to not use setreuid(2) and friends, like OpenBSD ksh and apparently pdksh. I'm not too sure about the implications, except that they only affect setuid shell scripts.
- Use setresuid(2) and friends, and setgroups(2) and <grp.h> instead of seteuid(2), setuid(2) etc. on operating systems that support them
- Work around (i.e. remove) all but two -Wcast-qual issues
- Work around a bug in the GNU implementation of the Berkeley mdoc macros which comes with GNU groff (only visible in MirOS with groff -mgdoc, but shows on other operating systems), discovered by crib in IRC
- $RANDOM is always an unsigned 15-bit decimal integer, for all Korn shell derivates; idea from twkm in IRC
- Improve/correct description of typeset command in manpage, and implementation of typeset -p in mksh
- Remove the non-standard emacs-usemeta and vi-show8 shell options, assume the user either has a 7-bit environment, an 8-bit clean terminal, or a UTF-8 environment (preferred), and the dummy sh option
- Build.sh fix for conservative (old) versions of gcc; help Debian
- Compute user-given ulimit value times ulimit unit as an rlim_t value, not as long value; catches some 32 bit overflows on 32 bit platforms due to a missing cast
- Fix some typos in the manual page
- Build.sh add notes for old and non-gcc compilers (TODO)
- Upgrade licence to latest template (revision 1.20)
- Fix reverse logic error in strcasecmp(3) vs strcasestr(3) issue
- Enhance sample ~/.mkshrc
- Prevent segfaults when setlocale(3) or nl_langinfo(3) return NULL
- Use RLIMIT_AS if RLIMIT_VMEM is not found
- Don't expand ~foo/ if MKSH_SMALL, spares getpwnam(3) call
- Fix and autoconfify signal list generation
- Build.sh now uses $TARGET_OS as "uname -s" output for cross builds
- Set flag for regression tests that can't succeed if MKSH_SMALL
- Don't even check for setlocale(3) if MKSH_SMALL, unless overridden by user / build environment
- Scan for C Preprocessor, use $CPP if $CC -E fails
- Fix possible nil pointer dereferences and signal name mismatches
- Scan for __attribute__((...)) and -std=gnu99 (req'd on Solaris 10)
- Correct $LDSTATIC logic, unbreak -d, don't let the user override (or need to) $SRCS, $sigseen
- Simplify TIOCGWINSZ handling, no need to catch SIGWINCH any more; window size changes are processed after input line editing ends (i.e. the lines are entered or ESC # (emacs mode) is pressed) and at startup; ^L (redraw) can't change window size on the fly
- Add -fwrapv to standard CFLAGS, just to be safe, like with when I added -fno-strict-aliasing; this is pending a bug fix in gcc, see PR#30477
- autoconfify compiler flags, c preprocessor
- add option to avoid pulling in getpwnam(3) in !MKSH_SMALL
- scan for certain headers, types; improve portability
- speed up autoconfiguration process in failure case
- finally fix static vs dynamic linking issues
- fix manpage (.Nm macro) glitch with GNU nroff 1.15
- improve auto-detection of which regression tests are valid
- mention failure to revoke(2) is possibly insecure
- if MKSH_SMALL, don't include -T support and don't scan for revoke() function
- new #ifdef MKSH_NEED_MKNOD to embed mknod(8) even if MKSH_SMALL is enabled
- do not scan for revoke() on GNU/Linux since it always fails
- simplify GNU/Linux CPPFLAGS and use them for GNU/HURD and GNU/kFreeBSD (tested on Debian experimental, thanks to the ftbfs.de autobuilder and Michael "azeem" Banck)
- fix the 'bind' (no args) builtin output
- new #ifdef MKSH_ASSUME_UTF8 to not check setlocale() and nl_langinfo(CODESET) if we want to always enable the utf-8 command line editing mode
- tabcomplete a newline to singlequote+newline+singlequote instead of backslash+newline which is eaten; thanks to Thomas E. "TGEN" Spanjaard for noticing
- remove shebang line from check.pl which isn't +x anyway
- fix 'hd' alias in dot.mkshrc example to not run off an ANSI standard 80 column screen; simplify
- integrate MKSH_NEED_MKNOD and MKSH_ASSUME_UTF8 with Build.sh
- Work around Solaris /usr/ucb/tr, Solaris /usr/xpg4/bin/tr, Minix 3 /usr/bin/tr, and SUSv3 deficiencies
- Fix compilation on more platforms (Interix, Cygwin, Linux 2.0 libc5, Debian GNU/kFreeBSD, Debian GNU/HURD, …)
- Use autoconfiguration for persistent history stuff
- Fix the code (add "const" in like 1001 places) to be able to build without -Wno-cast-qual (hope it's safe now)
- Optionally use const-debugging versions of strchr(3), strstr(3), to work around deficiencies in ANSI C
- The above directly led to our own strcasestr(3) implementation for OSes which don't have it
- Optimise dot.mkshrc macros
- Let dot.mkshrc not return failure early
- Remove shadowing warnings for more OSes
- Support old ash(1) versions in Build.sh
- Support use of _NSIG for NSIG
- Optimise ctags(1) generation
Upgrading to mksh R28 with these changes is highly recommended:
- For these who build software as root, the regression testsuite has been adapted to pass when using a priviledgued shell. You have been warned, though. Do not compile software as root.
- Fix some more -Wchar-subscripts on NetBSD®
- Adjust manual page to the fact that mksh can be used as /bin/sh although it's not specifically designed to
- Simplify mdoc/nroff macro load in manual page
- Add sample file: dot.mkshrc
- Correct and enhance book citation list in the manual page
- Bring back the "version" editing command in both emacs and vi modes, at ESC ^V like AT&T ksh93r+
- Fix typo which resulted in the wrong names for signals being printed (error codes were used instead) on GNU/Linux, Solaris and GNU/Cygwin. Ease changing signame/siglist sources.
- Some more code cleanup and redundancy removal
- Merge a few OpenBSD changes, yielding better multiline prompt support and textual improvements in the manual page
- Adjust $PS1 sizing, printing, and redrawal routines for mksh behaviour and single- and multiline prompts
- Unbreak build process on Cygwin, fix manpage generation
- For the AT&T $PS1 hack (second char = CR), do not output the delimiting characters any more, even if they are printable – fixes platforms without non-printable characters (Interix, Cygwin) and prompt size calculation
- Calculate length of prompt in lines and columns-of-last-line instead of using some tricks to skip the beginning of the prompt, resulting in correct redrawing of prompts with ANSI colour codes
- Correct displaying of prompts spanning more than one line and/or with embedded newlines or carriage returns; correct documentation of $PS1 and the redraw editing command
- Change one of the testsuite "expected failure" tests from bug to feature – it might actually be required by make(1)
- Enable to bind key sequences which consist of the usual optional one or two præfices and the control character, as well as an optional trailing tilde (if the trailing character is not a tilde, it's processed as usual, but processing of the editing command is postponed until after the trailing character has been read)
- Bind the NetBSD® wscons (vt220 / wsvt25), GNU screen and XFree86® (xterm-xfree86) "home", "end" and "delete" keys to ^A, ^E and ^D, respectively, except that "delete" does not act as logoff switch
- Correct Test.sh shebang line
- Make sure ^T is bound to 'transpose' as documented (bug spotted by hondza)
- Remove the 'stuff' and 'stuff-reset' editing commands
- Correct the manual page regarding the 'abort' command, its interaction with 'search-history' and how to exit the latter
- Bring back "set -o posix" turning off 'braceexpand'
- Mention IRC channel #mksh/Freenode in manual page
- Merge gensigs.sh into Build.sh, eliminating the need for $SHELL and making it more robust to broken user shells such as zsh, use the mksh just built for Test.sh; simplify CPPFLAGS and reduce size of generated table
- Run the signal name generator only if needed
- Use the -c option to GNU nroff, always
- Make the "all commands of a pipeline are executed in a subshell" issue a dependable mksh feature
- Improve regression test comments and a few tests
- If $RANDOM is generated from arc4random(3), display at most 31 bits of it like nbsh(1), instead of only 15 bits.
- Rename the regression test script from Test.sh to test.sh
- Improve Build.sh output regarding other files than the binary
- Mention #ksh/Freenode in the manual page, since its founder (twkm) said it's okay and on-topic as well
- Fix persistent history, add regression test
- Check for arc4random(3) and arc4random_push(3) by using the compiler instead of hardcoding OSes which have and which don't, because that's not always true
- Fix some regression tests (based upon user feedback too)
We recommended mksh R27e to be used:
- Allow Test.sh to be passed parameters (-v)
- Fix all -Wchar-subscripts on Solaris/sparc64 and NetBSD®/alpha and remove -Wno-char-subscripts from Build.sh
- Correct date in version and manual page
What became of mksh R27d in the meanwhile?
- Changes for easier crossbuildability
- Honour $CPPFLAGS in gensigs.sh
- Only source ${ENV:-~/.mkshrc} for interactive (FTALKING) shells
- There's a chance that non-MirOS systems have arc4random_push(3) at some time in the future, so make it configurable.
Featuring mksh R27c with these changes:
- emacs-usemeta now behaves like vi-show8 (be careful with 0x80-0x9F)
- Portability cleanup and speed-up; refine præprocessor defns
- GNU groff compatible manual page
- Fixes for Solaris 10 support
- Add ~/.mkshrc as $ENV feature (see manual page)
- Illustrate interactive shell tricks ($PS1) in manual page
- Enhance testsuite
- Incorporate some more code cleanup by OpenBSD
- Reference the O'Reilly books in the manual page
- R27c: fix packaging errors of previous versions
Changes in the minor version R26c, relative to R26b:
- Code cleanup by OpenBSD
- Documentation enhancements
- Fix gcc4 warnings in portable mksh
Changes in the minor version R26b, relative to R26:
- Makeup changes to copyright file (change comment leader)
- Sync licence with MirOS template (disclaimer changed a little)
- When building, generate a ./Test.sh on the fly which can be used instead of having to copy and paste a long line to run the regression test suite (still no way to run ifs.sh as we cannot distribute it, though).
- Add a few programming tricks to the manual page
- Fix abuse of unquoted characters in the manual page
- (no actual source code changes)
New major version R26 changed this, relative to R25b:
- Change the behaviour of \" in here documents to adhere SUSv3 (inspired by OpenBSD, most code by tg@)
New minor version R25b contains these changes:
- arc4random_push(3) does not exist on older MirOS systems; fixes build on MirOS #7quater
- Add GNU Cygwin to the list of supported platforms
New major version R25 contains these changes:
- Some manual page fixes and updates
- On window resizing, the COLUMNS and LINES variables are updated automatically, not only after the next command (from OpenBSD)
- Fix some redraw problem (from OpenBSD)
- Allow < and > for test and [, not only [[
- If an array index is out of bounds, tell which one (from OpenBSD)
- Add mknod(8) for pipes (user/root) and devices (root only) as a shell builtin – idea and some of the code from OpenBSD
- Improve compatibility with Solaris, GNU/Linux, Darwin, Interix
- Prevent redefinition of __rcsid string on systems without __RCSID macro (found by Han Boetes)
- Remove the need to manually specify -d on some OSes which need it
- Add a compiler flag to reduce some spurious Solaris-only warnings
R24c is another clean-up release, with no change to KSH_VERSION.
- Document stance on quoting policy in here documents
- More fixes for GCC 4 warnings
R24b is a minor clean-up relase, recommended especially on Darwin.
- please GCC 4 with the usual crazy set of warning flags
- remove 'version' editor binding and remap emacs ^V to quote-meta ('literal')
- use open(2) instead of creat(3), from OpenBSD
- [bsiegert] fix order of includes
- some code simplification; no explicit LFS needed any more
R24 is an important bug fix release and the new required minimum version to be installed for MirMake. Changes are:
- GNU/Cygwin is now supported but not officially tested
- DragonFly BSD is now supported and officially tested
- FreeBSD should work as a side effect of the above
- On NetBSD, arc4random(3) can now be used if it exists
- no longer look at argv[0] to determine if restricted shell
- changes to $EDITOR and $VISUAL no longer affect the current editing mode
- emacs on, emacs-usemeta off is now the default editing mode
- the special "posix" and "sh" modes are gone
- code, test suites and documentation have been cleaned up a little
- Korn's bizarre /dev/fd hack is now no longer supported
- undo fix for Debian PR #71256 which turned to be bogus and break make(1)
- fix compilation and invocation of test suite with whitespace in the pathnames for real, this time
- the distfile is now signed using gzsig(1)
R23 comes with an overhauled build system providing more flags for easier configuration, a bug-fix if the relative path to $0 contained a space, and does not need h2ph(1) to build some headers any more. Also, the code has cleaned up a bit and some manual page glitches were corrected. Some of these changes originated by Han Boetes, a few came via the OpenBSD project.
R22d is the first version which works if source or build directory contain spaces in the pathname. It also allows building without bothering to pre-format the manual page.
R22c contains some compile time warning fixes on non-MirOS platforms.
R22b contains an important fix regarding the srand(3) initialisation logic and a portability fix for NetBSD.
R22 is the result of three different kinds of work: integrating diffs from Debian's pdksh package, as needed, including fixing bugs and of course testing and fixing docs; fixing the dreaded emacs-mode filename with brackets (hello AONE); much cleanup and polishing. Also, the new codebase has been tested on a fair number of systems now, with more to follow (maybe even new, currently unsupported, platforms).
R20b contains some minor arc4random and build fixes against R20.
R21 has been a three-way integration work from OpenBSD-current's ksh, MirOS-current's ksh and portable mksh R20. This is the first release to come without autoconf'd script; it is much smaller and installs both faster and easier. Several bugs have been fixed, the testsuite has been enhanced and the code was cleaned up largely. pdksh lookalikeness was largely dropped, and support for octal and sedecimal (hexadecadic) numbers via prefixing with 0 or 0x has been added. This is an experimental release; it is not yet supported e.g. by MirMake – make(1) – or other tools but this will follow soon. MirbsdKsh R21 is to be the only shell available on MirOS #9.
R20 integrated an experimental bugfix from millert@openbsd and shuffled some code around. OS/2 support vanished, and the rest of the code shrank and was optimised. This is the first version since v1.11 to work on SFU (Interix) 3.5 as-is. The upgrade to R20 is highly recommended. Note: the mksh R20 distfile has changed from before Dec 14, 16:00.
R19 changes back a bugfix from R18 which caused a regression (from OpenBSD) and changed behaviour to match ksh88 on Solaris (from OpenBSD).
v1.18 (R18) fixes some core dump bugs and is a recommended update.
v1.17 comes out with the final MirOS licence template applied, but not yet OSI approved (it's not our fault though). There are regression fixes and bug fixes; IFS field splitting now works as documented. This version is a major improvement both over v1.16 and OpenBSD /bin/ksh, so please use it and report possible bugs.
v1.16 IS A BETA VERSION, use at your own risk. This version comes with a code cleanup session (for compilation with -Wall -Werror -W -pedantic and in preparation for doing an indent(1) whack over the source; any volunteers?) and some new features (with -T it spawns on a different tty than you're on - cool for single user mode) and code removed (the mailbox checking functionality, since everyone sane uses UW-IMAPD to access his MBX format folder using IMAPS, port 993, even to localhost). The code is also ANSIfied and protoised, in preparation for style(9) aka KNF.
There were no v1.13, v1.14, and v1.15 was never released as portable version. MirbsdKsh version numbers were pretty much RCS IDs at the time of writing this paragraph.
v1.12 fixes the manpages and minor stuff, as well as a signalling bug and the inability to build without gcc installed as gcc. It also adds installation hints for various operating systems.
v1.11 is a minor update to v1.10 with a few build and style fixes only.
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
- newer 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
- Can not [[ or (( yield the inode of a file, if we don’t get a stat(1) builtin? (For hashes by file.) Maybe make a builtin that expands struct stat into an associative array?
- 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
- 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
- /etc/mkshrc (maybe only if ~/.mkshrc does not exist, with similar rules; ENV=/ could be the magic "default" value; maybe go through $ENV -> ~/.mkshrc -> /etc/mkshrc by both existence and being >0 bytes...
- An option to rot13 the mirtoconf output (build log scanners are Moste Annoying)
