1 .\" $MirOS: src/bin/mksh/lksh.1,v 1.20 2016/11/11 23:31:35 tg Exp $
3 .\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015, 2016
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: November 11 2016 $
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 idiotic POSIX-mandated behaviour,
177 since the MirBSD Korn Shell scripting language is much more consistent.
179 Note that it's strongly recommended to invoke
183 option, if not both that
185 to fully enjoy better compatibility to the
187 standard (which is probably why you use
191 in the first place) or legacy scripts, respectively.
194 currently has the following differences from
198 .\"XXX TODO: remove (some systems may wish to have lksh as ksh)
199 There is no explicit support for interactive use,
200 nor any command line editing or history code.
203 is not suitable as a user's login shell, either; use
215 Note that the rest of the version string is identical between
216 the two shell flavours, and the behaviour and differences can
217 change between versions; see the accompanying manual page
219 for the versions this document applies to.
224 arithmetic, which has quite a few implications:
225 The data type for arithmetic operations is the host
230 Signed integer wraparound is Undefined Behaviour; this means that...
231 .Bd -literal -offset indent
232 $ echo $((2147483647 + 1))
235 \&... is permitted to, e.g. delete all files on your system
236 (the figure differs for non-32-bit systems, the rule doesn't).
237 The sign of the result of a modulo operation with at least one
238 negative operand is unspecified.
239 Shift operations on negative numbers are unspecified.
240 Division of the largest negative number by \-1 is Undefined Behaviour.
241 The compiler is permitted to delete all data and crash the system
242 if Undefined Behaviour occurs (see above for an example).
244 .\"XXX TODO: move this to FPOSIX
245 The rotation arithmetic operators are not available.
247 The shift arithmetic operators take all bits of the second operand into
248 account; if they exceed permitted precision, the result is unspecified.
250 .\"XXX TODO: move this to FPOSIX
254 extension &\*(Gt to redirect stdout and stderr in one go is not parsed.
256 .\"XXX TODO: drop along with allowing interactivity
267 always uses traditional mode for constructs like:
268 .Bd -literal -offset indent
269 $ set -- $(getopt ab:c "$@")
273 POSIX mandates this to show 0, but traditional mode
274 passes through the errorlevel from the
278 .\"XXX TODO: move to FPOSIX/FSH
289 do not keep file descriptors \*(Gt 2 private from sub-processes.
291 Functions defined with the
293 reserved word share the shell options
295 instead of locally scoping them.
300 .Pa https://www.mirbsd.org/mksh.htm
302 .Pa https://www.mirbsd.org/ksh\-chan.htm
304 The distinction between the shell variants
305 .Pq Nm lksh / Nm mksh
307 .Pq Fl o Ic posix / Ic sh
308 will be reworked for an upcoming release.
314 compilation to enable
316 by default if called as
318 is highly recommended for better standards compliance.
319 For better compatibility with legacy scripts, such as many
321 maintainer scripts, Upstart and SYSV init scripts, and other
322 unfixed scripts, using the compile-time options for enabling
324 .Ic set -o posix -o sh
325 when the shell is run as
330 tries to make a cross between a legacy bourne/posix compatibl-ish
331 shell and a legacy pdksh-alike but
333 is not exactly specified.
337 built-in command does not currently have all options one would expect
345 development team using the mailing list at
346 .Aq miros\-mksh@mirbsd.org
352 .Pq Port 6697 SSL, 6667 unencrypted
353 if you need any further quirks or assistance,
354 and consider migrating your legacy scripts to work with