1LKSH(1)                   BSD General Commands Manual                  LKSH(1)
2

NAME

4     lksh — Legacy Korn shell built on mksh
5

SYNOPSIS

7     lksh [-+abCefhiklmnprUuvXx] [-+o opt] [-c string | -s | file [args ...]]
8

DESCRIPTION

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 objectionable POSIX-mandated behaviour,
14     since the MirBSD Korn Shell scripting language is much more consistent.
15
16     Do not use lksh as an interactive or login shell; use mksh instead.
17
18     Note that it's strongly recommended to invoke lksh with -o posix to fully
19     enjoy better compatibility to the POSIX standard (which is probably why
20     you use lksh over mksh in the first place); -o sh (possibly additionally
21     to the above) may be needed for some legacy scripts.
22

LEGACY MODE

24     lksh currently has the following differences from mksh:
25
26     ·   The KSH_VERSION string identifies lksh as “LEGACY KSH” instead of
27         “MIRBSD KSH”.  Note that the rest of the version string is identical
28         between the two shell flavours, and the behaviour and differences can
29         change between versions; see the accompanying manual page mksh(1) for
30         the versions this document applies to.
31
32     ·   lksh uses POSIX arithmetic, which has quite a few implications: The
33         data type for arithmetic operations is the host ISO C long data type.
34         Signed integer wraparound is Undefined Behaviour; this means that...
35
36               $ echo $((2147483647 + 1))
37
38         ... is permitted to, e.g. delete all files on your system (the figure
39         differs for non-32-bit systems, the rule doesn't).  The sign of the
40         result of a modulo operation with at least one negative operand is
41         unspecified.  Shift operations on negative numbers are unspecified.
42         Division of the largest negative number by -1 is Undefined Behaviour.
43         The compiler is permitted to delete all data and crash the system if
44         Undefined Behaviour occurs (see above for an example).
45
46     ·   The rotation arithmetic operators are not available.
47
48     ·   The shift arithmetic operators take all bits of the second operand
49         into account; if they exceed permitted precision, the result is
50         unspecified.
51
52     ·   Unless set -o posix is active, lksh always uses traditional mode for
53         constructs like:
54
55               $ set -- $(getopt ab:c "$@")
56               $ echo $?
57
58         POSIX mandates this to show 0, but traditional mode passes through
59         the errorlevel from the getopt(1) command.
60
61     ·   Functions defined with the function reserved word share the shell
62         options (set -o) instead of locally scoping them.
63

SEE ALSO

65     mksh(1)
66
67     http://www.mirbsd.org/mksh.htm
68
69     http://www.mirbsd.org/ksh-chan.htm
70

CAVEATS

72     To use lksh as /bin/sh, compilation to enable set -o posix by default if
73     called as sh (adding -DMKSH_BINSHPOSIX to CPPFLAGS) is highly recommended
74     for better standards compliance.
75
76     For better compatibility with legacy scripts, such as many Debian main‐
77     tainer scripts, Upstart and SYSV init scripts, and other unfixed scripts,
78     also adding the -DMKSH_BINSHREDUCED compile-time option to enable both
79     set -o posix -o sh when the shell is run as sh, as well as integrating
80     the optional disrecommended printf(1) builtin, might be necessary.
81
82     lksh tries to make a cross between a legacy bourne/posix compatibl-ish
83     shell and a legacy pdksh-alike but “legacy” is not exactly specified.
84
85     Talk to the MirBSD development team and users using the mailing list at
86     <miros-mksh@mirbsd.org> (please note the EU-DSGVO/GDPR notice on
87     http://www.mirbsd.org/rss.htm#lists and in the SMTP banner!) or the
88     #!/bin/mksh (or #ksh) IRC channel at irc.freenode.net (Port 6697 SSL,
89     6667 unencrypted) if you need any further quirks or assistance, and con‐
90     sider migrating your legacy scripts to work with mksh instead of requir‐
91     ing lksh.
92
93MirBSD                         December 25, 2018                        MirBSD
Impressum