1 .\" $MirOS: src/bin/mksh/lksh.1,v 1.16 2015/12/12 22:25:14 tg Exp $
3 .\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015
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 \& especially with two-letter words.
31 .\" The section after the "doc" macropackage has been loaded contains
32 .\" additional code to convene between the UCB mdoc macropackage (and
33 .\" its variant as BSD mdoc in groff) and the GNU mdoc macropackage.
36 . if
\ 1\*[.T]
\ 1ascii
\ 1 .tr \-\N'45'
37 . if
\ 1\*[.T]
\ 1latin1
\ 1 .tr \-\N'45'
38 . if
\ 1\*[.T]
\ 1utf8
\ 1 .tr \-\N'45'
45 . if
\ 1\*[.T]
\ 1utf8
\ 1 .ds sL `
46 . if
\ 1\*[.T]
\ 1ps
\ 1 .ds sL `
47 . if
\ 1\*[.T]
\ 1utf8
\ 1 .ds sR '
48 . if
\ 1\*[.T]
\ 1ps
\ 1 .ds sR '
61 .\" Implement .Dd with the Mdocdate RCS keyword
65 .ie
\a\\$1
\a$Mdocdate:
\a \{\
68 .el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
71 .\" .Dd must come before definition of .Mx, because when called
72 .\" with -mandoc, it might implement .Mx itself, but we want to
73 .\" use our own definition. And .Dd must come *first*, always.
75 .Dd $Mdocdate: December 12 2015 $
77 .\" Check which macro package we use, and do other -mdoc setup.
80 . if
\ 1\*[.T]
\ 1utf8
\ 1 .tr \[la]\*(Lt
81 . if
\ 1\*[.T]
\ 1utf8
\ 1 .tr \[ra]\*(Gt
82 . ie d volume-ds-1 .ds tT gnu
87 .\" Implement .Mx (MirBSD)
93 . nr curr-size \n[.ps]
94 . ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u]
95 . ds str-Mx1 \*[Tn-font-size]\%MirOS\*[str-Mx]
101 . if (\n[arg-limit] > \n[arg-ptr]) \{\
103 . ie (\n[type\n[arg-ptr]] == 2) \
104 . as str-Mx1 \~\*[arg\n[arg-ptr]]
108 . ds arg\n[arg-ptr] "\*[str-Mx1]
109 . nr type\n[arg-ptr] 2
110 . ds space\n[arg-ptr] "\*[space]
111 . nr num-args (\n[arg-limit] - \n[arg-ptr])
112 . nr arg-limit \n[arg-ptr]
119 . ds tN \*[Tn-font-size]
125 . ds aa \&\f\\n(cF\s\\n(cZ
127 . ie \\n(.$==0 \&MirOS\\*(aa
128 . el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
130 . if \\n(aC>\\n(aP \{\
132 . ie \\n(C\\n(aP==2 \{\
133 . as b1 \&MirOS\ #\&\\*(A\\n(aP\\*(aa
134 . ie \\n(aC>\\n(aP \{\
141 . as b1 \&MirOS\\*(aa
152 .Nd Legacy Korn shell built on mksh
156 .Op Fl +abCefhiklmnprUuvXx
159 .Fl c Ar string \*(Ba
167 is a command interpreter intended exclusively for running legacy
171 refer to its manual page for details on the scripting language.
172 It is recommended to port scripts to
174 instead of relying on legacy or idiotic POSIX-mandated behaviour,
175 since the MirBSD Korn Shell scripting language is much more consistent.
177 Note that it's strongly recommended to invoke
181 option, if not both that
183 to fully enjoy better compatibility to the
185 standard (which is probably why you use
189 in the first place) or legacy scripts, respectively.
192 currently has the following differences from
196 .\"XXX TODO: remove (some systems may wish to have lksh as ksh)
197 There is no explicit support for interactive use,
198 nor any command line editing or history code.
201 is not suitable as a user's login shell, either; use
213 Note that the rest of the version string is identical between
214 the two shell flavours, and the behaviour and differences can
215 change between versions; see the accompanying manual page
217 for the versions this document applies to.
222 arithmetics, which has quite a few implications:
223 The data type for arithmetics is the host
228 Signed integer wraparound is Undefined Behaviour; this means that...
229 .Bd -literal -offset indent
230 $ echo $((2147483647 + 1))
233 \&... is permitted to, e.g. delete all files on your system
234 (the figure differs for non-32-bit systems, the rule doesn't).
235 The sign of the result of a modulo operation with at least one
236 negative operand is unspecified.
237 Shift operations on negative numbers are unspecified.
238 Division of the largest negative number by \-1 is Undefined Behaviour.
239 The compiler is permitted to delete all data and crash the system
240 if Undefined Behaviour occurs (see above for an example).
243 only offers the traditional ten file descriptors to scripts.
245 .\"XXX TODO: move this to FPOSIX
246 The rotation arithmetic operators are not available.
248 The shift arithmetic operators take all bits of the second operand into
249 account; if they exceed permitted precision, the result is unspecified.
251 .\"XXX TODO: move this to FPOSIX
255 extension &\*(Gt to redirect stdout and stderr in one go is not parsed.
257 .\"XXX TODO: drop along with allowing interactivity
268 always uses traditional mode for constructs like:
269 .Bd -literal -offset indent
270 $ set -- $(getopt ab:c "$@")
274 POSIX mandates this to show 0, but traditional mode
275 passes through the errorlevel from the
279 .\"XXX TODO: move to FPOSIX/FSH
290 do not keep file descriptors \*(Gt 2 private from sub-processes.
292 Functions defined with the
294 reserved word share the shell options
296 instead of locally scoping them.
301 .Pa https://www.mirbsd.org/mksh.htm
303 .Pa https://www.mirbsd.org/ksh\-chan.htm
305 The distinction between the shell variants
306 .Pq Nm lksh / Nm mksh
308 .Pq Fl o Ic posix / Ic sh
309 will be reworked for an upcoming release.
315 compilation to enable
317 by default if called as
319 is highly recommended for better standards compliance.
320 For better compatibility with legacy scripts, such as many
322 maintainer scripts, Upstart and SYSV init scripts, and other
323 unfixed scripts, using the compile-time options for enabling
325 .Ic set -o posix -o sh
326 when the shell is run as
331 tries to make a cross between a legacy bourne/posix compatibl-ish
332 shell and a legacy pdksh-alike but
334 is not exactly specified.
338 built-in command does not currently have all options one would expect
346 development team using the mailing list at
347 .Aq miros\-mksh@mirbsd.org
353 .Pq Port 6697 SSL, 6667 unencrypted
354 if you need any further quirks or assistance,
355 and consider migrating your legacy scripts to work with