1LKSH(1) BSD General Commands Manual LKSH(1)
2
4 lksh — Legacy Korn shell built on mksh
5
7 lksh [-+abCefhiklmnprUuvXx] [-+o opt] [-c string | -s | file [args ...]]
8
10 lksh is a command interpreter intended exclusively for running legacy
11 shell scripts. It is built on mksh; refer to its manual page for details
12 on the scripting language. It is recommended to port scripts to mksh
13 instead of relying on legacy or idiotic POSIX-mandated behaviour, since
14 the MirBSD Korn Shell scripting language is much more consistent.
15
17 lksh has the following differences from mksh:
18
19 · lksh is not suitable for use as /bin/sh.
20
21 · There is no explicit support for interactive use, nor any command
22 line editing or history code. Hence, lksh is not suitable as a
23 user's login shell, either; use mksh instead.
24
25 · The KSH_VERSION string identifies lksh as “LEGACY KSH” instead of
26 “MIRBSD KSH”.
27
28 · lksh only offers the traditional ten file descriptors to scripts.
29
30 · lksh uses POSIX arithmetics, which has quite a few implications: The
31 data type for arithmetics is the host ISO C long data type. Signed
32 integer wraparound is Undefined Behaviour. The sign of the result of
33 a modulo operation with at least one negative operand is unspecified.
34 Shift operations on negative numbers are unspecified. Division of
35 the largest negative number by -1 is Undefined Behaviour. The com‐
36 piler is permitted to delete all data and crash the system if Unde‐
37 fined Behaviour occurs.
38
39 · The rotation arithmetic operators are not available.
40
41 · The shift arithmetic operators take all bits of the second operand
42 into account; if they exceed permitted precision, the result is
43 unspecified.
44
45 · The GNU bash extension &> to redirect stdout and stderr in one go is
46 not parsed.
47
48 · The mksh command line option -T is not available.
49
50 · Unless set -o posix is active, lksh always uses traditional mode for
51 constructs like:
52
53 $ set -- $(getopt ab:c "$@")
54 $ echo $?
55
56 POSIX mandates this to show 0, but traditional mode passes through
57 the errorlevel from the getopt(1) command.
58
59 · lksh, unlike AT&T UNIX ksh, does not keep file descriptors > 2 pri‐
60 vate.
61
63 mksh(1)
64
65 https://www.mirbsd.org/mksh.htm
66
67 https://www.mirbsd.org/ksh-chan.htm
68
70 lksh tries to make a cross between a legacy bourne/posix compatibl-ish
71 shell and a legacy pdksh-alike but “legacy” is not exactly specified.
72
73 The set built-in command does not have all options one would expect from
74 a full-blown mksh or pdksh.
75
76 Talk to the MirOS development team using the mailing list at
77 <miros-mksh@mirbsd.org> or the #!/bin/mksh (or #ksh) IRC channel at
78 irc.freenode.net (Port 6697 SSL, 6667 unencrypted) if you need any fur‐
79 ther quirks or assistance, and consider migrating your legacy scripts to
80 work with mksh instead of requiring lksh.
81
82MirBSD May 2, 2013 MirBSD