1 .\" $MirOS: src/bin/mksh/lksh.1,v 1.10 2015/04/12 22:32:12 tg Exp $
3 .\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015
4 .\" Thorsten “mirabilos” Glaser <tg@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: April 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.
178 currently has the following differences from
182 There is no explicit support for interactive use,
183 nor any command line editing or history code.
186 is not suitable as a user's login shell, either; use
198 Note that the rest of the version string is identical between
199 the two shell flavours, and the behaviour and differences can
200 change between versions; see the accompanying manual page
202 for the versions this document applies to.
205 only offers the traditional ten file descriptors to scripts.
210 arithmetics, which has quite a few implications:
211 The data type for arithmetics is the host ISO C
214 Signed integer wraparound is Undefined Behaviour.
215 The sign of the result of a modulo operation with at least one
216 negative operand is unspecified.
217 Shift operations on negative numbers are unspecified.
218 Division of the largest negative number by \-1 is Undefined Behaviour.
219 The compiler is permitted to delete all data and crash the system
220 if Undefined Behaviour occurs.
222 The rotation arithmetic operators are not available.
224 The shift arithmetic operators take all bits of the second operand into
225 account; if they exceed permitted precision, the result is unspecified.
230 extension &\*(Gt to redirect stdout and stderr in one go is not parsed.
242 always uses traditional mode for constructs like:
243 .Bd -literal -offset indent
244 $ set -- $(getopt ab:c "$@")
248 POSIX mandates this to show 0, but traditional mode
249 passes through the errorlevel from the
263 do not keep file descriptors \*(Gt 2 private from sub-processes.
266 undefines an alias when a
268 function with the same name is defined,
269 to make that function immediately callable.
272 aliases have precedence; the name must be quoted or
276 Functions defined with the
278 reserved word share the shell options
280 instead of locally scoping them.
285 .Pa https://www.mirbsd.org/mksh.htm
287 .Pa https://www.mirbsd.org/ksh\-chan.htm
293 compilation to enable
295 by default is highly recommended for better standards compliance.
298 tries to make a cross between a legacy bourne/posix compatibl-ish
299 shell and a legacy pdksh-alike but
301 is not exactly specified.
305 built-in command does not have all options one would expect
313 development team using the mailing list at
314 .Aq miros\-mksh@mirbsd.org
320 .Pq Port 6697 SSL, 6667 unencrypted
321 if you need any further quirks or assistance,
322 and consider migrating your legacy scripts to work with