1*7c356e86SAndroid Build Coastguard Worker.\" $MirOS: src/bin/mksh/lksh.1,v 1.26 2020/09/04 22:37:01 tg Exp $ 2*7c356e86SAndroid Build Coastguard Worker.\"- 3*7c356e86SAndroid Build Coastguard Worker.\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015, 2016, 2017, 2018 4*7c356e86SAndroid Build Coastguard Worker.\" mirabilos <[email protected]> 5*7c356e86SAndroid Build Coastguard Worker.\" 6*7c356e86SAndroid Build Coastguard Worker.\" Provided that these terms and disclaimer and all copyright notices 7*7c356e86SAndroid Build Coastguard Worker.\" are retained or reproduced in an accompanying document, permission 8*7c356e86SAndroid Build Coastguard Worker.\" is granted to deal in this work without restriction, including un‐ 9*7c356e86SAndroid Build Coastguard Worker.\" limited rights to use, publicly perform, distribute, sell, modify, 10*7c356e86SAndroid Build Coastguard Worker.\" merge, give away, or sublicence. 11*7c356e86SAndroid Build Coastguard Worker.\" 12*7c356e86SAndroid Build Coastguard Worker.\" This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to 13*7c356e86SAndroid Build Coastguard Worker.\" the utmost extent permitted by applicable law, neither express nor 14*7c356e86SAndroid Build Coastguard Worker.\" implied; without malicious intent or gross negligence. In no event 15*7c356e86SAndroid Build Coastguard Worker.\" may a licensor, author or contributor be held liable for indirect, 16*7c356e86SAndroid Build Coastguard Worker.\" direct, other damage, loss, or other issues arising in any way out 17*7c356e86SAndroid Build Coastguard Worker.\" of dealing in the work, even if advised of the possibility of such 18*7c356e86SAndroid Build Coastguard Worker.\" damage or existence of a defect, except proven that it results out 19*7c356e86SAndroid Build Coastguard Worker.\" of said person’s immediate fault when using the work as intended. 20*7c356e86SAndroid Build Coastguard Worker.\"- 21*7c356e86SAndroid Build Coastguard Worker.\" Try to make GNU groff and AT&T nroff more compatible 22*7c356e86SAndroid Build Coastguard Worker.\" * ` generates ‘ in gnroff, so use \` 23*7c356e86SAndroid Build Coastguard Worker.\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq 24*7c356e86SAndroid Build Coastguard Worker.\" * - generates ‐ in gnroff, \- generates −, so .tr it to - 25*7c356e86SAndroid Build Coastguard Worker.\" thus use - for hyphens and \- for minus signs and option dashes 26*7c356e86SAndroid Build Coastguard Worker.\" * ~ is size-reduced and placed atop in groff, so use \*(TI 27*7c356e86SAndroid Build Coastguard Worker.\" * ^ is size-reduced and placed atop in groff, so use \*(ha 28*7c356e86SAndroid Build Coastguard Worker.\" * \(en does not work in nroff, so use \*(en for a solo en dash 29*7c356e86SAndroid Build Coastguard Worker.\" * and \*(EM for a correctly spaced em dash 30*7c356e86SAndroid Build Coastguard Worker.\" * <>| are problematic, so redefine and use \*(Lt\*(Gt\*(Ba 31*7c356e86SAndroid Build Coastguard Worker.\" Also make sure to use \& *before* a punctuation char that is to not 32*7c356e86SAndroid Build Coastguard Worker.\" be interpreted as punctuation, and especially with two-letter words 33*7c356e86SAndroid Build Coastguard Worker.\" but also (after) a period that does not end a sentence (“e.g.\&”). 34*7c356e86SAndroid Build Coastguard Worker.\" The section after the "doc" macropackage has been loaded contains 35*7c356e86SAndroid Build Coastguard Worker.\" additional code to convene between the UCB mdoc macropackage (and 36*7c356e86SAndroid Build Coastguard Worker.\" its variant as BSD mdoc in groff) and the GNU mdoc macropackage. 37*7c356e86SAndroid Build Coastguard Worker.\" 38*7c356e86SAndroid Build Coastguard Worker.ie \n(.g \{\ 39*7c356e86SAndroid Build Coastguard Worker. if \*[.T]ascii .tr \-\N'45' 40*7c356e86SAndroid Build Coastguard Worker. if \*[.T]latin1 .tr \-\N'45' 41*7c356e86SAndroid Build Coastguard Worker. if \*[.T]utf8 .tr \-\N'45' 42*7c356e86SAndroid Build Coastguard Worker. ds <= \[<=] 43*7c356e86SAndroid Build Coastguard Worker. ds >= \[>=] 44*7c356e86SAndroid Build Coastguard Worker. ds Rq \[rq] 45*7c356e86SAndroid Build Coastguard Worker. ds Lq \[lq] 46*7c356e86SAndroid Build Coastguard Worker. ds sL \(aq 47*7c356e86SAndroid Build Coastguard Worker. ds sR \(aq 48*7c356e86SAndroid Build Coastguard Worker. if \*[.T]utf8 .ds sL ` 49*7c356e86SAndroid Build Coastguard Worker. if \*[.T]ps .ds sL ` 50*7c356e86SAndroid Build Coastguard Worker. if \*[.T]utf8 .ds sR ' 51*7c356e86SAndroid Build Coastguard Worker. if \*[.T]ps .ds sR ' 52*7c356e86SAndroid Build Coastguard Worker. ds aq \(aq 53*7c356e86SAndroid Build Coastguard Worker. ds TI \(ti 54*7c356e86SAndroid Build Coastguard Worker. ds ha \(ha 55*7c356e86SAndroid Build Coastguard Worker. ds en \(en 56*7c356e86SAndroid Build Coastguard Worker.\} 57*7c356e86SAndroid Build Coastguard Worker.el \{\ 58*7c356e86SAndroid Build Coastguard Worker. ds aq ' 59*7c356e86SAndroid Build Coastguard Worker. ds TI ~ 60*7c356e86SAndroid Build Coastguard Worker. ds ha ^ 61*7c356e86SAndroid Build Coastguard Worker. ds en \(em 62*7c356e86SAndroid Build Coastguard Worker.\} 63*7c356e86SAndroid Build Coastguard Worker.ie n \{\ 64*7c356e86SAndroid Build Coastguard Worker. ds EM \ \*(en\ \& 65*7c356e86SAndroid Build Coastguard Worker.\} 66*7c356e86SAndroid Build Coastguard Worker.el \{\ 67*7c356e86SAndroid Build Coastguard Worker. ds EM \f(TR\^\(em\^\fP 68*7c356e86SAndroid Build Coastguard Worker.\} 69*7c356e86SAndroid Build Coastguard Worker.\" 70*7c356e86SAndroid Build Coastguard Worker.\" Implement .Dd with the Mdocdate RCS keyword 71*7c356e86SAndroid Build Coastguard Worker.\" 72*7c356e86SAndroid Build Coastguard Worker.rn Dd xD 73*7c356e86SAndroid Build Coastguard Worker.de Dd 74*7c356e86SAndroid Build Coastguard Worker.ie \\$1$Mdocdate: \{\ 75*7c356e86SAndroid Build Coastguard Worker. xD \\$2 \\$3, \\$4 76*7c356e86SAndroid Build Coastguard Worker.\} 77*7c356e86SAndroid Build Coastguard Worker.el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 78*7c356e86SAndroid Build Coastguard Worker.. 79*7c356e86SAndroid Build Coastguard Worker.\" 80*7c356e86SAndroid Build Coastguard Worker.\" .Dd must come before definition of .Mx, because when called 81*7c356e86SAndroid Build Coastguard Worker.\" with -mandoc, it might implement .Mx itself, but we want to 82*7c356e86SAndroid Build Coastguard Worker.\" use our own definition. And .Dd must come *first*, always. 83*7c356e86SAndroid Build Coastguard Worker.\" 84*7c356e86SAndroid Build Coastguard Worker.Dd $Mdocdate: September 4 2020 $ 85*7c356e86SAndroid Build Coastguard Worker.\" 86*7c356e86SAndroid Build Coastguard Worker.\" Check which macro package we use, and do other -mdoc setup. 87*7c356e86SAndroid Build Coastguard Worker.\" 88*7c356e86SAndroid Build Coastguard Worker.ie \n(.g \{\ 89*7c356e86SAndroid Build Coastguard Worker. if \*[.T]utf8 .tr \[la]\*(Lt 90*7c356e86SAndroid Build Coastguard Worker. if \*[.T]utf8 .tr \[ra]\*(Gt 91*7c356e86SAndroid Build Coastguard Worker. ie d volume-ds-1 .ds tT gnu 92*7c356e86SAndroid Build Coastguard Worker. el .ie d doc-volume-ds-1 .ds tT gnp 93*7c356e86SAndroid Build Coastguard Worker. el .ds tT bsd 94*7c356e86SAndroid Build Coastguard Worker.\} 95*7c356e86SAndroid Build Coastguard Worker.el .ds tT ucb 96*7c356e86SAndroid Build Coastguard Worker.\" 97*7c356e86SAndroid Build Coastguard Worker.\" Implement .Mx (MirBSD) 98*7c356e86SAndroid Build Coastguard Worker.\" 99*7c356e86SAndroid Build Coastguard Worker.ie "\*(tT"gnu" \{\ 100*7c356e86SAndroid Build Coastguard Worker. eo 101*7c356e86SAndroid Build Coastguard Worker. de Mx 102*7c356e86SAndroid Build Coastguard Worker. nr curr-font \n[.f] 103*7c356e86SAndroid Build Coastguard Worker. nr curr-size \n[.ps] 104*7c356e86SAndroid Build Coastguard Worker. ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u] 105*7c356e86SAndroid Build Coastguard Worker. ds str-Mx1 \*[Tn-font-size]\%MirBSD\*[str-Mx] 106*7c356e86SAndroid Build Coastguard Worker. if !\n[arg-limit] \ 107*7c356e86SAndroid Build Coastguard Worker. if \n[.$] \{\ 108*7c356e86SAndroid Build Coastguard Worker. ds macro-name Mx 109*7c356e86SAndroid Build Coastguard Worker. parse-args \$@ 110*7c356e86SAndroid Build Coastguard Worker. \} 111*7c356e86SAndroid Build Coastguard Worker. if (\n[arg-limit] > \n[arg-ptr]) \{\ 112*7c356e86SAndroid Build Coastguard Worker. nr arg-ptr +1 113*7c356e86SAndroid Build Coastguard Worker. ie (\n[type\n[arg-ptr]] == 2) \ 114*7c356e86SAndroid Build Coastguard Worker. as str-Mx1 \~\*[arg\n[arg-ptr]] 115*7c356e86SAndroid Build Coastguard Worker. el \ 116*7c356e86SAndroid Build Coastguard Worker. nr arg-ptr -1 117*7c356e86SAndroid Build Coastguard Worker. \} 118*7c356e86SAndroid Build Coastguard Worker. ds arg\n[arg-ptr] "\*[str-Mx1] 119*7c356e86SAndroid Build Coastguard Worker. nr type\n[arg-ptr] 2 120*7c356e86SAndroid Build Coastguard Worker. ds space\n[arg-ptr] "\*[space] 121*7c356e86SAndroid Build Coastguard Worker. nr num-args (\n[arg-limit] - \n[arg-ptr]) 122*7c356e86SAndroid Build Coastguard Worker. nr arg-limit \n[arg-ptr] 123*7c356e86SAndroid Build Coastguard Worker. if \n[num-args] \ 124*7c356e86SAndroid Build Coastguard Worker. parse-space-vector 125*7c356e86SAndroid Build Coastguard Worker. print-recursive 126*7c356e86SAndroid Build Coastguard Worker.. 127*7c356e86SAndroid Build Coastguard Worker. ec 128*7c356e86SAndroid Build Coastguard Worker. ds sP \s0 129*7c356e86SAndroid Build Coastguard Worker. ds tN \*[Tn-font-size] 130*7c356e86SAndroid Build Coastguard Worker.\} 131*7c356e86SAndroid Build Coastguard Worker.el .ie "\*(tT"gnp" \{\ 132*7c356e86SAndroid Build Coastguard Worker. eo 133*7c356e86SAndroid Build Coastguard Worker. de Mx 134*7c356e86SAndroid Build Coastguard Worker. nr doc-curr-font \n[.f] 135*7c356e86SAndroid Build Coastguard Worker. nr doc-curr-size \n[.ps] 136*7c356e86SAndroid Build Coastguard Worker. ds doc-str-Mx \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u] 137*7c356e86SAndroid Build Coastguard Worker. ds doc-str-Mx1 \*[doc-Tn-font-size]\%MirBSD\*[doc-str-Mx] 138*7c356e86SAndroid Build Coastguard Worker. if !\n[doc-arg-limit] \ 139*7c356e86SAndroid Build Coastguard Worker. if \n[.$] \{\ 140*7c356e86SAndroid Build Coastguard Worker. ds doc-macro-name Mx 141*7c356e86SAndroid Build Coastguard Worker. doc-parse-args \$@ 142*7c356e86SAndroid Build Coastguard Worker. \} 143*7c356e86SAndroid Build Coastguard Worker. if (\n[doc-arg-limit] > \n[doc-arg-ptr]) \{\ 144*7c356e86SAndroid Build Coastguard Worker. nr doc-arg-ptr +1 145*7c356e86SAndroid Build Coastguard Worker. ie (\n[doc-type\n[doc-arg-ptr]] == 2) \ 146*7c356e86SAndroid Build Coastguard Worker. as doc-str-Mx1 \~\*[doc-arg\n[doc-arg-ptr]] 147*7c356e86SAndroid Build Coastguard Worker. el \ 148*7c356e86SAndroid Build Coastguard Worker. nr doc-arg-ptr -1 149*7c356e86SAndroid Build Coastguard Worker. \} 150*7c356e86SAndroid Build Coastguard Worker. ds doc-arg\n[doc-arg-ptr] "\*[doc-str-Mx1] 151*7c356e86SAndroid Build Coastguard Worker. nr doc-type\n[doc-arg-ptr] 2 152*7c356e86SAndroid Build Coastguard Worker. ds doc-space\n[doc-arg-ptr] "\*[doc-space] 153*7c356e86SAndroid Build Coastguard Worker. nr doc-num-args (\n[doc-arg-limit] - \n[doc-arg-ptr]) 154*7c356e86SAndroid Build Coastguard Worker. nr doc-arg-limit \n[doc-arg-ptr] 155*7c356e86SAndroid Build Coastguard Worker. if \n[doc-num-args] \ 156*7c356e86SAndroid Build Coastguard Worker. doc-parse-space-vector 157*7c356e86SAndroid Build Coastguard Worker. doc-print-recursive 158*7c356e86SAndroid Build Coastguard Worker.. 159*7c356e86SAndroid Build Coastguard Worker. ec 160*7c356e86SAndroid Build Coastguard Worker. ds sP \s0 161*7c356e86SAndroid Build Coastguard Worker. ds tN \*[doc-Tn-font-size] 162*7c356e86SAndroid Build Coastguard Worker.\} 163*7c356e86SAndroid Build Coastguard Worker.el \{\ 164*7c356e86SAndroid Build Coastguard Worker. de Mx 165*7c356e86SAndroid Build Coastguard Worker. nr cF \\n(.f 166*7c356e86SAndroid Build Coastguard Worker. nr cZ \\n(.s 167*7c356e86SAndroid Build Coastguard Worker. ds aa \&\f\\n(cF\s\\n(cZ 168*7c356e86SAndroid Build Coastguard Worker. if \\n(aC==0 \{\ 169*7c356e86SAndroid Build Coastguard Worker. ie \\n(.$==0 \&MirBSD\\*(aa 170*7c356e86SAndroid Build Coastguard Worker. el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 171*7c356e86SAndroid Build Coastguard Worker. \} 172*7c356e86SAndroid Build Coastguard Worker. if \\n(aC>\\n(aP \{\ 173*7c356e86SAndroid Build Coastguard Worker. nr aP \\n(aP+1 174*7c356e86SAndroid Build Coastguard Worker. ie \\n(C\\n(aP==2 \{\ 175*7c356e86SAndroid Build Coastguard Worker. as b1 \&MirBSD\ #\&\\*(A\\n(aP\\*(aa 176*7c356e86SAndroid Build Coastguard Worker. ie \\n(aC>\\n(aP \{\ 177*7c356e86SAndroid Build Coastguard Worker. nr aP \\n(aP+1 178*7c356e86SAndroid Build Coastguard Worker. nR 179*7c356e86SAndroid Build Coastguard Worker. \} 180*7c356e86SAndroid Build Coastguard Worker. el .aZ 181*7c356e86SAndroid Build Coastguard Worker. \} 182*7c356e86SAndroid Build Coastguard Worker. el \{\ 183*7c356e86SAndroid Build Coastguard Worker. as b1 \&MirBSD\\*(aa 184*7c356e86SAndroid Build Coastguard Worker. nR 185*7c356e86SAndroid Build Coastguard Worker. \} 186*7c356e86SAndroid Build Coastguard Worker. \} 187*7c356e86SAndroid Build Coastguard Worker.. 188*7c356e86SAndroid Build Coastguard Worker.\} 189*7c356e86SAndroid Build Coastguard Worker.\"- 190*7c356e86SAndroid Build Coastguard Worker.Dt LKSH 1 191*7c356e86SAndroid Build Coastguard Worker.Os MirBSD 192*7c356e86SAndroid Build Coastguard Worker.Sh NAME 193*7c356e86SAndroid Build Coastguard Worker.Nm lksh 194*7c356e86SAndroid Build Coastguard Worker.Nd Legacy Korn shell built on mksh 195*7c356e86SAndroid Build Coastguard Worker.Sh SYNOPSIS 196*7c356e86SAndroid Build Coastguard Worker.Nm 197*7c356e86SAndroid Build Coastguard Worker.Bk -words 198*7c356e86SAndroid Build Coastguard Worker.Op Fl +abCefhiklmnprUuvXx 199*7c356e86SAndroid Build Coastguard Worker.Op Fl +o Ar opt 200*7c356e86SAndroid Build Coastguard Worker.Oo 201*7c356e86SAndroid Build Coastguard Worker.Fl c Ar string \*(Ba 202*7c356e86SAndroid Build Coastguard Worker.Fl s \*(Ba 203*7c356e86SAndroid Build Coastguard Worker.Ar file 204*7c356e86SAndroid Build Coastguard Worker.Op Ar args ... 205*7c356e86SAndroid Build Coastguard Worker.Oc 206*7c356e86SAndroid Build Coastguard Worker.Ek 207*7c356e86SAndroid Build Coastguard Worker.Sh DESCRIPTION 208*7c356e86SAndroid Build Coastguard Worker.Nm 209*7c356e86SAndroid Build Coastguard Workeris a command interpreter intended exclusively for running legacy 210*7c356e86SAndroid Build Coastguard Workershell scripts. 211*7c356e86SAndroid Build Coastguard WorkerIt is built on 212*7c356e86SAndroid Build Coastguard Worker.Nm mksh ; 213*7c356e86SAndroid Build Coastguard Workerrefer to its manual page for details on the scripting language. 214*7c356e86SAndroid Build Coastguard WorkerIt is recommended to port scripts to 215*7c356e86SAndroid Build Coastguard Worker.Nm mksh 216*7c356e86SAndroid Build Coastguard Workerinstead of relying on legacy or objectionable POSIX-mandated behaviour, 217*7c356e86SAndroid Build Coastguard Workersince the MirBSD Korn Shell scripting language is much more consistent. 218*7c356e86SAndroid Build Coastguard Worker.Pp 219*7c356e86SAndroid Build Coastguard WorkerDo not use 220*7c356e86SAndroid Build Coastguard Worker.Nm 221*7c356e86SAndroid Build Coastguard Workeras an interactive or login shell; use 222*7c356e86SAndroid Build Coastguard Worker.Nm mksh 223*7c356e86SAndroid Build Coastguard Workerinstead. 224*7c356e86SAndroid Build Coastguard Worker.Pp 225*7c356e86SAndroid Build Coastguard WorkerNote that it's strongly recommended to invoke 226*7c356e86SAndroid Build Coastguard Worker.Nm 227*7c356e86SAndroid Build Coastguard Workerwith 228*7c356e86SAndroid Build Coastguard Worker.Fl o Ic posix 229*7c356e86SAndroid Build Coastguard Workerto fully enjoy better compatibility to the 230*7c356e86SAndroid Build Coastguard Worker.Tn POSIX 231*7c356e86SAndroid Build Coastguard Workerstandard (which is probably why you use 232*7c356e86SAndroid Build Coastguard Worker.Nm 233*7c356e86SAndroid Build Coastguard Workerover 234*7c356e86SAndroid Build Coastguard Worker.Nm mksh 235*7c356e86SAndroid Build Coastguard Workerin the first place); 236*7c356e86SAndroid Build Coastguard Worker.Fl o Ic sh 237*7c356e86SAndroid Build Coastguard Worker(possibly additionally to the above) may be needed for some legacy scripts. 238*7c356e86SAndroid Build Coastguard Worker.Sh LEGACY MODE 239*7c356e86SAndroid Build Coastguard Worker.Nm 240*7c356e86SAndroid Build Coastguard Workercurrently has the following differences from 241*7c356e86SAndroid Build Coastguard Worker.Nm mksh : 242*7c356e86SAndroid Build Coastguard Worker.Bl -bullet 243*7c356e86SAndroid Build Coastguard Worker.It 244*7c356e86SAndroid Build Coastguard WorkerThe 245*7c356e86SAndroid Build Coastguard Worker.Ev KSH_VERSION 246*7c356e86SAndroid Build Coastguard Workerstring identifies 247*7c356e86SAndroid Build Coastguard Worker.Nm 248*7c356e86SAndroid Build Coastguard Workeras 249*7c356e86SAndroid Build Coastguard Worker.Dq Li LEGACY KSH 250*7c356e86SAndroid Build Coastguard Workerinstead of 251*7c356e86SAndroid Build Coastguard Worker.Dq Li MIRBSD KSH . 252*7c356e86SAndroid Build Coastguard WorkerNote that the rest of the version string is identical between 253*7c356e86SAndroid Build Coastguard Workerthe two shell flavours, and the behaviour and differences can 254*7c356e86SAndroid Build Coastguard Workerchange between versions; see the accompanying manual page 255*7c356e86SAndroid Build Coastguard Worker.Xr mksh 1 256*7c356e86SAndroid Build Coastguard Workerfor the versions this document applies to. 257*7c356e86SAndroid Build Coastguard Worker.It 258*7c356e86SAndroid Build Coastguard Worker.Nm 259*7c356e86SAndroid Build Coastguard Workeruses 260*7c356e86SAndroid Build Coastguard Worker.Tn POSIX 261*7c356e86SAndroid Build Coastguard Workerarithmetic, which has quite a few implications: 262*7c356e86SAndroid Build Coastguard WorkerThe data type for arithmetic operations is the host 263*7c356e86SAndroid Build Coastguard Worker.Tn ISO 264*7c356e86SAndroid Build Coastguard WorkerC 265*7c356e86SAndroid Build Coastguard Worker.Vt long 266*7c356e86SAndroid Build Coastguard Workerdata type. 267*7c356e86SAndroid Build Coastguard WorkerSigned integer wraparound is Undefined Behaviour; this means that... 268*7c356e86SAndroid Build Coastguard Worker.Bd -literal -offset indent 269*7c356e86SAndroid Build Coastguard Worker$ echo $((2147483647 + 1)) 270*7c356e86SAndroid Build Coastguard Worker.Ed 271*7c356e86SAndroid Build Coastguard Worker.Pp 272*7c356e86SAndroid Build Coastguard Worker\&... is permitted to, e.g. delete all files on your system 273*7c356e86SAndroid Build Coastguard Worker(the figure differs for non-32-bit systems, the rule doesn't). 274*7c356e86SAndroid Build Coastguard WorkerThe sign of the result of a modulo operation with at least one 275*7c356e86SAndroid Build Coastguard Workernegative operand is unspecified. 276*7c356e86SAndroid Build Coastguard WorkerShift operations on negative numbers are unspecified. 277*7c356e86SAndroid Build Coastguard WorkerDivision of the largest negative number by \-1 is Undefined Behaviour. 278*7c356e86SAndroid Build Coastguard WorkerThe compiler is permitted to delete all data and crash the system 279*7c356e86SAndroid Build Coastguard Workerif Undefined Behaviour occurs (see above for an example). 280*7c356e86SAndroid Build Coastguard Worker.It 281*7c356e86SAndroid Build Coastguard WorkerThe rotation arithmetic operators are not available. 282*7c356e86SAndroid Build Coastguard Worker.It 283*7c356e86SAndroid Build Coastguard WorkerThe shift arithmetic operators take all bits of the second operand into 284*7c356e86SAndroid Build Coastguard Workeraccount; if they exceed permitted precision, the result is unspecified. 285*7c356e86SAndroid Build Coastguard Worker.It 286*7c356e86SAndroid Build Coastguard WorkerUnless 287*7c356e86SAndroid Build Coastguard Worker.Ic set -o posix 288*7c356e86SAndroid Build Coastguard Workeris active, 289*7c356e86SAndroid Build Coastguard Worker.Nm 290*7c356e86SAndroid Build Coastguard Workeralways uses traditional mode for constructs like: 291*7c356e86SAndroid Build Coastguard Worker.Bd -literal -offset indent 292*7c356e86SAndroid Build Coastguard Worker$ set -- $(getopt ab:c "$@") 293*7c356e86SAndroid Build Coastguard Worker$ echo $? 294*7c356e86SAndroid Build Coastguard Worker.Ed 295*7c356e86SAndroid Build Coastguard Worker.Pp 296*7c356e86SAndroid Build Coastguard WorkerPOSIX mandates this to show 0, but traditional mode 297*7c356e86SAndroid Build Coastguard Workerpasses through the errorlevel from the 298*7c356e86SAndroid Build Coastguard Worker.Xr getopt 1 299*7c356e86SAndroid Build Coastguard Workercommand. 300*7c356e86SAndroid Build Coastguard Worker.It 301*7c356e86SAndroid Build Coastguard WorkerFunctions defined with the 302*7c356e86SAndroid Build Coastguard Worker.Ic function 303*7c356e86SAndroid Build Coastguard Workerreserved word share the shell options 304*7c356e86SAndroid Build Coastguard Worker.Pq Ic set -o 305*7c356e86SAndroid Build Coastguard Workerinstead of locally scoping them. 306*7c356e86SAndroid Build Coastguard Worker.El 307*7c356e86SAndroid Build Coastguard Worker.Sh SEE ALSO 308*7c356e86SAndroid Build Coastguard Worker.Xr mksh 1 309*7c356e86SAndroid Build Coastguard Worker.Pp 310*7c356e86SAndroid Build Coastguard Worker.Pa http://www.mirbsd.org/mksh.htm 311*7c356e86SAndroid Build Coastguard Worker.Pp 312*7c356e86SAndroid Build Coastguard Worker.Pa http://www.mirbsd.org/ksh\-chan.htm 313*7c356e86SAndroid Build Coastguard Worker.Sh CAVEATS 314*7c356e86SAndroid Build Coastguard WorkerTo use 315*7c356e86SAndroid Build Coastguard Worker.Nm 316*7c356e86SAndroid Build Coastguard Workeras 317*7c356e86SAndroid Build Coastguard Worker.Pa /bin/sh , 318*7c356e86SAndroid Build Coastguard Workercompilation to enable 319*7c356e86SAndroid Build Coastguard Worker.Ic set -o posix 320*7c356e86SAndroid Build Coastguard Workerby default if called as 321*7c356e86SAndroid Build Coastguard Worker.Nm sh 322*7c356e86SAndroid Build Coastguard Worker.Pq adding Dv \-DMKSH_BINSHPOSIX to Dv CPPFLAGS 323*7c356e86SAndroid Build Coastguard Workeris highly recommended for better standards compliance. 324*7c356e86SAndroid Build Coastguard Worker.Pp 325*7c356e86SAndroid Build Coastguard WorkerFor better compatibility with legacy scripts, such as many 326*7c356e86SAndroid Build Coastguard Worker.Tn Debian 327*7c356e86SAndroid Build Coastguard Workermaintainer scripts, Upstart and SYSV init scripts, and other 328*7c356e86SAndroid Build Coastguard Workerunfixed scripts, also adding the 329*7c356e86SAndroid Build Coastguard Worker.Dv \-DMKSH_BINSHREDUCED 330*7c356e86SAndroid Build Coastguard Workercompile-time option to enable 331*7c356e86SAndroid Build Coastguard Worker.Em both 332*7c356e86SAndroid Build Coastguard Worker.Ic set -o posix -o sh 333*7c356e86SAndroid Build Coastguard Workerwhen the shell is run as 334*7c356e86SAndroid Build Coastguard Worker.Nm sh , 335*7c356e86SAndroid Build Coastguard Workeras well as integrating the optional disrecommended 336*7c356e86SAndroid Build Coastguard Worker.Xr printf 1 337*7c356e86SAndroid Build Coastguard Workerbuiltin, might be necessary. 338*7c356e86SAndroid Build Coastguard Worker.Pp 339*7c356e86SAndroid Build Coastguard Worker.Nm 340*7c356e86SAndroid Build Coastguard Workertries to make a cross between a legacy bourne/posix compatibl-ish 341*7c356e86SAndroid Build Coastguard Workershell and a legacy pdksh-alike but 342*7c356e86SAndroid Build Coastguard Worker.Dq legacy 343*7c356e86SAndroid Build Coastguard Workeris not exactly specified. 344*7c356e86SAndroid Build Coastguard Worker.Pp 345*7c356e86SAndroid Build Coastguard WorkerTalk to the 346*7c356e86SAndroid Build Coastguard Worker.Mx 347*7c356e86SAndroid Build Coastguard Workerdevelopment team and users using the mailing list at 348*7c356e86SAndroid Build Coastguard Worker.Aq Mt miros\[email protected] 349*7c356e86SAndroid Build Coastguard Worker(please note the EU-DSGVO/GDPR notice on 350*7c356e86SAndroid Build Coastguard Worker.Pa http://www.mirbsd.org/rss.htm#lists 351*7c356e86SAndroid Build Coastguard Workerand in the SMTP banner!) or the 352*7c356e86SAndroid Build Coastguard Worker.Li \&#\&!/bin/mksh 353*7c356e86SAndroid Build Coastguard Worker.Pq or Li \&#ksh 354*7c356e86SAndroid Build Coastguard WorkerIRC channel at 355*7c356e86SAndroid Build Coastguard Worker.Pa irc.freenode.net 356*7c356e86SAndroid Build Coastguard Worker.Pq Port 6697 SSL, 6667 unencrypted 357*7c356e86SAndroid Build Coastguard Workerif you need any further quirks or assistance, 358*7c356e86SAndroid Build Coastguard Workerand consider migrating your legacy scripts to work with 359*7c356e86SAndroid Build Coastguard Worker.Nm mksh 360*7c356e86SAndroid Build Coastguard Workerinstead of requiring 361*7c356e86SAndroid Build Coastguard Worker.Nm . 362