LKSH(1)
π LKSH(1) β the legacy Korn shell manual, but make it make sense π
okay bestie, so you're reading the lksh page from the General Commands Manual, and honestly? it's giving "old shell, new girl". sit down, grab a boba, and let's get into it π§β¨
πΈ NAME πΈ
lksh β a Legacy Korn shell built on top of mksh. that's the whole vibe. legacy. iconic. slightly cursed. periodt π
β¨ SYNOPSIS β¨
lksh [-+abCefhiklmnprUuvXx] [-+o opt] [-c string | -s | file [args ...]]
like, that's the whole summoning ritual. flags, options, a string, a stdin mode, or a file with args. pick your fighter π
π¦ DESCRIPTION π¦
lksh is a command interpreter and it is intended exclusively for running legacy shell scripts. that's its whole job, its whole personality, its whole main character arc. it is built on mksh, so if you want the actual tea on the scripting language, go read its manual page. no cap.
and here's the thing, bestie: it is recommended that you port scripts to mksh instead of relying on legacy or objectionable POSIX-mandated behaviour, because the MirBSD Korn Shell scripting language is much more consistent. it's giving "glow up, but for your shell scripts". β¨
π¨ do not uselkshas an interactive or login shell. usemkshinstead. that's not a suggestion, that's a boundary, and we respect boundaries in this house π
also, strongly recommended: invoke lksh with -o posix so you can fully enjoy better compatibility to the POSIX standard (which is probably literally why you're using lksh over mksh in the first place, be honest π). and -o sh β possibly in addition to the above β may be needed for some legacy scripts. stack 'em, bestie.
π LEGACY MODE π
so rn, lksh has these differences from mksh. buckle up, there's lore:
- the
KSH_VERSIONstring identifieslkshas βLEGACY KSHβ instead of βMIRBSD KSHβ. note that the rest of the version string is identical between the two shell flavours, and the behaviour and differences can change between versions; see the accompanying manual pagemksh(1)for the versions this document applies to. iykyk π«Ά lkshuses POSIX arithmetic, which has quite a few implications, and bestie some of them are scary π:- the data type for arithmetic operations is the host ISO C
longdata type. - Signed integer wraparound is Undefined Behaviour β and this means that...
- the data type for arithmetic operations is the host ISO C
$ echo $((2147483647 + 1))
...is permitted to, e.g. delete all files on your system. (the figure differs for non-32-bit systems, the rule doesn't. the rule never does. π)
- the sign of the result of a modulo operation with at least one negative operand is unspecified.
- shift operations on negative numbers are unspecified.
- division of the largest negative number by
-1is Undefined Behaviour. - the compiler is permitted to delete all data and crash the system if Undefined Behaviour occurs (see above for an example). not me being dramatic, that's just literally what it says π«
- the rotation arithmetic operators are not available. they're gone, bestie. don't look for them.
- the shift arithmetic operators take all bits of the second operand into account; if they exceed permitted precision, the result is unspecified.
- unless
set -o posixis active,lkshalways uses traditional mode for constructs like:
$ set -- $(getopt ab:c "$@")
$ echo $?
POSIX mandates this to show 0, but traditional mode passes through the errorlevel from the getopt(1) command. different behaviour, same drama β¨
- functions defined with the
functionreserved word share the shell options (set -o) instead of locally scoping them. so they're not being private about it, they're sharing. iconique, but also watch out.
π SEE ALSO π
mksh(1)β go read this one, seriously, it's the blueprint π«Ά- http://www.mirbsd.org/mksh.htm
- http://www.mirbsd.org/ksh-chan.htm
π CAVEATS π
to use lksh as /bin/sh, compilation to enable set -o posix by default if called as sh (adding -DMKSH_BINSHPOSIX to CPPFLAGS) is highly recommended for better standards compliance. like, please. for the standards. π₯Ί
for better compatibility with legacy scripts β such as many Debian maintainer scripts, Upstart and SYSV init scripts, and other unfixed scripts β also adding the -DMKSH_BINSHREDUCED compile-time option to enable both set -o posix -o sh when the shell is run as sh, as well as integrating the optional disrecommended printf(1) builtin, might be necessary. (disrecommended, but sometimes necessary. it's giving "toxic ex you still text". π)
lksh tries to make a cross between a legacy bourne/posix compatibl-ish shell and a legacy pdksh-alike but βlegacyβ is not exactly specified. yeah. we know. it's a vibe, not a spec. π
talk to the MirBSD development team and users using the mailing list at <miros-mksh@mirbsd.org> (please note the EU-DSGVO/GDPR notice on http://www.mirbsd.org/rss.htm#lists and in the SMTP banner!) or the #!/bin/mksh (or #ksh) IRC channel at irc.freenode.net (Port 6697 SSL, 6667 unencrypted) if you need any further quirks or assistance β and consider migrating your legacy scripts to work with mksh instead of requiring lksh. bestie, that last part is the real advice π
and that's the page!! this one's from the MirBSD crew, dated September 4, 2020. thanks for coming to my ted talk, now go port your scripts to mksh π
β¨π¦
π¦ where this page comes from
- centos-stream 10: mksh 59c-13.el10 Β· MirOS AND ISC
- centos-stream 9: mksh 59c-6.el9 Β· MirOS and ISC and BSD
- fedora 43: mksh 59c-14.fc43 Β· MirOS AND ISC
- fedora 44: mksh 59c-15.fc44 Β· MirOS AND ISC
- opensuse-leap 16.0: mksh 59c-160000.2.2 Β· ISC AND MirOS
- opensuse-leap 16.0: mksh 59c-160000.2.2 Β· ISC AND MirOS
- opensuse-leap 16.0: mksh 59c-160000.2.2 Β· ISC AND MirOS
- opensuse-leap 16.0: mksh 59c-160000.2.2 Β· ISC AND MirOS
- Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015, 2016, 2017, 2018 mirabilos <m@mirbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms