1 .\" $MirOS: src/bin/mksh/lksh.1,v 1.23 2017/04/02 13:38:02 tg Exp $
3 .\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015, 2016, 2017
4 .\" mirabilos <m@mirbsd.org>
6 .\" Provided that these terms and disclaimer and all copyright notices
7 .\" are retained or reproduced in an accompanying document, permission
8 .\" is granted to deal in this work without restriction, including un‐
9 .\" limited rights to use, publicly perform, distribute, sell, modify,
10 .\" merge, give away, or sublicence.
12 .\" This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
13 .\" the utmost extent permitted by applicable law, neither express nor
14 .\" implied; without malicious intent or gross negligence. In no event
15 .\" may a licensor, author or contributor be held liable for indirect,
16 .\" direct, other damage, loss, or other issues arising in any way out
17 .\" of dealing in the work, even if advised of the possibility of such
18 .\" damage or existence of a defect, except proven that it results out
19 .\" of said person’s immediate fault when using the work as intended.
21 .\" Try to make GNU groff and AT&T nroff more compatible
22 .\" * ` generates ‘ in gnroff, so use \`
23 .\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq
24 .\" * - generates ‐ in gnroff, \- generates −, so .tr it to -
25 .\" thus use - for hyphens and \- for minus signs and option dashes
26 .\" * ~ is size-reduced and placed atop in groff, so use \*(TI
27 .\" * ^ is size-reduced and placed atop in groff, so use \*(ha
28 .\" * \(en does not work in nroff, so use \*(en
29 .\" * <>| are problematic, so redefine and use \*(Lt\*(Gt\*(Ba
30 .\" Also make sure to use \& *before* a punctuation char that is to not
31 .\" be interpreted as punctuation, and especially with two-letter words
32 .\" but also (after) a period that does not end a sentence (“e.g.\&”).
33 .\" The section after the "doc" macropackage has been loaded contains
34 .\" additional code to convene between the UCB mdoc macropackage (and
35 .\" its variant as BSD mdoc in groff) and the GNU mdoc macropackage.
38 . if
\ 1\*[.T]
\ 1ascii
\ 1 .tr \-\N'45'
39 . if
\ 1\*[.T]
\ 1latin1
\ 1 .tr \-\N'45'
40 . if
\ 1\*[.T]
\ 1utf8
\ 1 .tr \-\N'45'
47 . if
\ 1\*[.T]
\ 1utf8
\ 1 .ds sL `
48 . if
\ 1\*[.T]
\ 1ps
\ 1 .ds sL `
49 . if
\ 1\*[.T]
\ 1utf8
\ 1 .ds sR '
50 . if
\ 1\*[.T]
\ 1ps
\ 1 .ds sR '
63 .\" Implement .Dd with the Mdocdate RCS keyword
67 .ie
\a\\$1
\a$Mdocdate:
\a \{\
70 .el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
73 .\" .Dd must come before definition of .Mx, because when called
74 .\" with -mandoc, it might implement .Mx itself, but we want to
75 .\" use our own definition. And .Dd must come *first*, always.
77 .Dd $Mdocdate: April 2 2017 $
79 .\" Check which macro package we use, and do other -mdoc setup.
82 . if
\ 1\*[.T]
\ 1utf8
\ 1 .tr \[la]\*(Lt
83 . if
\ 1\*[.T]
\ 1utf8
\ 1 .tr \[ra]\*(Gt
84 . ie d volume-ds-1 .ds tT gnu
89 .\" Implement .Mx (MirBSD)
95 . nr curr-size \n[.ps]
96 . ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u]
97 . ds str-Mx1 \*[Tn-font-size]\%MirOS\*[str-Mx]
103 . if (\n[arg-limit] > \n[arg-ptr]) \{\
105 . ie (\n[type\n[arg-ptr]] == 2) \
106 . as str-Mx1 \~\*[arg\n[arg-ptr]]
110 . ds arg\n[arg-ptr] "\*[str-Mx1]
111 . nr type\n[arg-ptr] 2
112 . ds space\n[arg-ptr] "\*[space]
113 . nr num-args (\n[arg-limit] - \n[arg-ptr])
114 . nr arg-limit \n[arg-ptr]
121 . ds tN \*[Tn-font-size]
127 . ds aa \&\f\\n(cF\s\\n(cZ
129 . ie \\n(.$==0 \&MirOS\\*(aa
130 . el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
132 . if \\n(aC>\\n(aP \{\
134 . ie \\n(C\\n(aP==2 \{\
135 . as b1 \&MirOS\ #\&\\*(A\\n(aP\\*(aa
136 . ie \\n(aC>\\n(aP \{\
143 . as b1 \&MirOS\\*(aa
154 .Nd Legacy Korn shell built on mksh
158 .Op Fl +abCefhiklmnprUuvXx
161 .Fl c Ar string \*(Ba
169 is a command interpreter intended exclusively for running legacy
173 refer to its manual page for details on the scripting language.
174 It is recommended to port scripts to
176 instead of relying on legacy or objectionable POSIX-mandated behaviour,
177 since the MirBSD Korn Shell scripting language is much more consistent.
181 as an interactive or login shell; use
185 Note that it's strongly recommended to invoke
189 to fully enjoy better compatibility to the
191 standard (which is probably why you use
197 (possibly additionally to the above) may be needed for some legacy scripts.
200 currently has the following differences from
212 Note that the rest of the version string is identical between
213 the two shell flavours, and the behaviour and differences can
214 change between versions; see the accompanying manual page
216 for the versions this document applies to.
221 arithmetic, which has quite a few implications:
222 The data type for arithmetic operations is the host
227 Signed integer wraparound is Undefined Behaviour; this means that...
228 .Bd -literal -offset indent
229 $ echo $((2147483647 + 1))
232 \&... is permitted to, e.g. delete all files on your system
233 (the figure differs for non-32-bit systems, the rule doesn't).
234 The sign of the result of a modulo operation with at least one
235 negative operand is unspecified.
236 Shift operations on negative numbers are unspecified.
237 Division of the largest negative number by \-1 is Undefined Behaviour.
238 The compiler is permitted to delete all data and crash the system
239 if Undefined Behaviour occurs (see above for an example).
241 The rotation arithmetic operators are not available.
243 The shift arithmetic operators take all bits of the second operand into
244 account; if they exceed permitted precision, the result is unspecified.
250 always uses traditional mode for constructs like:
251 .Bd -literal -offset indent
252 $ set -- $(getopt ab:c "$@")
256 POSIX mandates this to show 0, but traditional mode
257 passes through the errorlevel from the
261 Functions defined with the
263 reserved word share the shell options
265 instead of locally scoping them.
270 .Pa http://www.mirbsd.org/mksh.htm
272 .Pa http://www.mirbsd.org/ksh\-chan.htm
278 compilation to enable
280 by default if called as
282 .Pq adding Dv \-DMKSH_BINSHPOSIX to Dv CPPFLAGS
283 is highly recommended for better standards compliance.
285 For better compatibility with legacy scripts, such as many
287 maintainer scripts, Upstart and SYSV init scripts, and other
288 unfixed scripts, also adding the
289 .Dv \-DMKSH_BINSHREDUCED
290 compile-time option to enable
292 .Ic set -o posix -o sh
293 when the shell is run as
295 as well as integrating the optional disrecommended
297 builtin, might be necessary.
300 tries to make a cross between a legacy bourne/posix compatibl-ish
301 shell and a legacy pdksh-alike but
303 is not exactly specified.
307 development team using the mailing list at
308 .Aq miros\-mksh@mirbsd.org
314 .Pq Port 6697 SSL, 6667 unencrypted
315 if you need any further quirks or assistance,
316 and consider migrating your legacy scripts to work with