diff --git a/.gitignore b/.gitignore index 534882d..2e9f05e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -mksh-R40d.cpio.gz +mksh-*.tgz diff --git a/lksh.1 b/lksh.1 new file mode 100644 index 0000000..d040352 --- /dev/null +++ b/lksh.1 @@ -0,0 +1,265 @@ +.\" $MirOS: contrib/hosted/tg/deb/mksh/debian/lksh.1,v 1.4 2012/06/30 17:24:36 tg Exp $ +.\"- +.\" Copyright (c) 2008, 2009, 2010, 2012 +.\" Thorsten “mirabilos” Glaser +.\"- +.\" Try to make GNU groff and AT&T nroff more compatible +.\" * ` generates ‘ in gnroff, so use \` +.\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq +.\" * - generates ‐ in gnroff, \- generates −, so .tr it to - +.\" thus use - for hyphens and \- for minus signs and option dashes +.\" * ~ is size-reduced and placed atop in groff, so use \*(TI +.\" * ^ is size-reduced and placed atop in groff, so use \*(ha +.\" * \(en does not work in nroff, so use \*(en +.\" * <>| are problematic, so redefine and use \*(Lt\*(Gt\*(Ba +.\" Also make sure to use \& especially with two-letter words. +.\" The section after the "doc" macropackage has been loaded contains +.\" additional code to convene between the UCB mdoc macropackage (and +.\" its variant as BSD mdoc in groff) and the GNU mdoc macropackage. +.\" +.ie \n(.g \{\ +. if \*[.T]ascii .tr \-\N'45' +. if \*[.T]latin1 .tr \-\N'45' +. if \*[.T]utf8 .tr \-\N'45' +. ds <= \[<=] +. ds >= \[>=] +. ds Rq \[rq] +. ds Lq \[lq] +. ds sL \(aq +. ds sR \(aq +. if \*[.T]utf8 .ds sL ` +. if \*[.T]ps .ds sL ` +. if \*[.T]utf8 .ds sR ' +. if \*[.T]ps .ds sR ' +. ds aq \(aq +. ds TI \(ti +. ds ha \(ha +. ds en \(en +.\} +.el \{\ +. ds aq ' +. ds TI ~ +. ds ha ^ +. ds en \(em +.\} +.\" +.\" Implement .Dd with the Mdocdate RCS keyword +.\" +.rn Dd xD +.de Dd +.ie \\$1$Mdocdate: \{\ +. xD \\$2 \\$3, \\$4 +.\} +.el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 +.. +.\" +.\" .Dd must come before definition of .Mx, because when called +.\" with -mandoc, it might implement .Mx itself, but we want to +.\" use our own definition. And .Dd must come *first*, always. +.\" +.Dd $Mdocdate: June 30 2012 $ +.\" +.\" Check which macro package we use, and do other -mdoc setup. +.\" +.ie \n(.g \{\ +. if \*[.T]utf8 .tr \[la]\*(Lt +. if \*[.T]utf8 .tr \[ra]\*(Gt +. ie d volume-ds-1 .ds tT gnu +. el .ds tT bsd +.\} +.el .ds tT ucb +.\" +.\" Implement .Mx (MirBSD) +.\" +.ie "\*(tT"gnu" \{\ +. eo +. de Mx +. nr curr-font \n[.f] +. nr curr-size \n[.ps] +. ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u] +. ds str-Mx1 \*[Tn-font-size]\%MirOS\*[str-Mx] +. if !\n[arg-limit] \ +. if \n[.$] \{\ +. ds macro-name Mx +. parse-args \$@ +. \} +. if (\n[arg-limit] > \n[arg-ptr]) \{\ +. nr arg-ptr +1 +. ie (\n[type\n[arg-ptr]] == 2) \ +. as str-Mx1 \~\*[arg\n[arg-ptr]] +. el \ +. nr arg-ptr -1 +. \} +. ds arg\n[arg-ptr] "\*[str-Mx1] +. nr type\n[arg-ptr] 2 +. ds space\n[arg-ptr] "\*[space] +. nr num-args (\n[arg-limit] - \n[arg-ptr]) +. nr arg-limit \n[arg-ptr] +. if \n[num-args] \ +. parse-space-vector +. print-recursive +.. +. ec +. ds sP \s0 +. ds tN \*[Tn-font-size] +.\} +.el \{\ +. de Mx +. nr cF \\n(.f +. nr cZ \\n(.s +. ds aa \&\f\\n(cF\s\\n(cZ +. if \\n(aC==0 \{\ +. ie \\n(.$==0 \&MirOS\\*(aa +. el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 +. \} +. if \\n(aC>\\n(aP \{\ +. nr aP \\n(aP+1 +. ie \\n(C\\n(aP==2 \{\ +. as b1 \&MirOS\ #\&\\*(A\\n(aP\\*(aa +. ie \\n(aC>\\n(aP \{\ +. nr aP \\n(aP+1 +. nR +. \} +. el .aZ +. \} +. el \{\ +. as b1 \&MirOS\\*(aa +. nR +. \} +. \} +.. +.\} +.\"- +.Dt LKSH 1 +.Os MirBSD +.Sh NAME +.Nm lksh +.Nd Legacy Korn shell built on mksh +.Sh SYNOPSIS +.Nm +.Bk -words +.Op Fl +abCefhiklmnprUuvXx +.Op Fl +o Ar opt +.Oo +.Fl c Ar string \*(Ba +.Fl s \*(Ba +.Ar file +.Op Ar args ... +.Oc +.Ek +.Sh DESCRIPTION +.Nm +is a command interpreter intended exclusive for running legacy +shell scripts. +It is built on +.Nm mksh ; +refer to its manual page for details on the scripting language. +.Sh LEGACY MODE +.Nm +has the following differences from +.Nm mksh : +.Bl -bullet +.It +.Nm +is not suitable for use as +.Pa /bin/sh . +.It +There is no explicit support for interactive use, +nor any command line editing code. +Hence, +.Nm +is not suitable as a user's login shell, either; use +.Nm mksh +instead. +.It +The +.Ev KSH_VERSION +string identifies +.Nm +as +.Dq LEGACY KSH +instead of +.Dq MIRBSD KSH . +.It +Some +.Nm mksh +specific extensions are missing; specifically, the +.Fl T +command-line option. +.It +.Nm +always uses traditional mode for constructs like: +.Bd -literal -offset indent +$ set -- $(getopt ab:c "$@") +$ echo $? +.Ed +.Pp +POSIX mandates this to show 0, but traditional mode +passes through the errorlevel from the +.Xr getopt 1 +command. +.It +.Nm lksh , +unlike +.At +.Nm ksh , +does not keep file descriptors \*(Gt 2 private. +.It +.Nm +parses leading-zero numbers as octal (base 8). +.It +Integers use the host C environment's +.Vt long +type, not +.Vt int32_t . +Unsigned arithmetic is done using +.Vt unsigned long , +not +.Vt uint32_t . +Neither value limits nor wraparound is guaranteed. +Dividing the largest negative number by \-1 is Undefined Behaviour +.Po +but might work on 32-bit and 64-bit +.Vt long +types +.Pc . +.El +.Sh SEE ALSO +.Xr mksh 1 +.Pp +.Pa https://www.mirbsd.org/mksh.htm +.Pp +.Pa https://www.mirbsd.org/ksh\-chan.htm +.Sh CAVEATS +.Nm +tries to make a cross between a legacy bourne/posix compatibl-ish +shell and a legacy pdksh-alike but +.Dq legacy +is not exactly specified. +Parsing numbers with leading zero digits or +.Dq 0x +is relatively recent in all +.Nm pdksh +derivates, but supported here for completeness. +It might make sense to make this a run-time option, but +that might also be overkill. +.Pp +The +.Ic set +built-in command does not have all options one would expect +from a full-blown +.Nm mksh +or +.Nm pdksh . +.Pp +Talk to the +.Mx +development team using the mailing list at +.Aq miros\-discuss@mirbsd.org +or the +.Li \&#\&!/bin/mksh +.Pq or Li \&#ksh +IRC channel at +.Pa irc.freenode.net +.Pq Port 6697 SSL, 6667 unencrypted +if you need any further quirks. diff --git a/mksh.spec b/mksh.spec index 82e7452..828a381 100644 --- a/mksh.spec +++ b/mksh.spec @@ -1,15 +1,16 @@ %define _bindir /bin - Summary: MirBSD enhanced version of the Korn Shell Name: mksh -Version: 40d +Version: 44 Release: 1%{?dist} # BSD (setmode.c), ISC (strlcpy.c), MirOS (the rest) License: MirOS and ISC and BSD Group: System Environment/Shells URL: http://www.mirbsd.de/%{name}.htm -Source0: http://www.mirbsd.org/MirOS/dist/mir/%{name}/%{name}-R%{version}.cpio.gz +Source0: http://www.mirbsd.org/MirOS/dist/mir/%{name}/%{name}-R%{version}.tgz Source1: dot-mkshrc +Source2: lksh.1 +Source3: rtchecks.expected Requires(post): grep Requires(postun): sed BuildRequires: util-linux, ed @@ -23,33 +24,76 @@ modern, robust shell good for interactive and especially script use, being a bourne shell replacement, pdksh successor and an alternative to the C shell. %prep -%setup -q -T -c - -# rpm.org has no support for *.cpio.gz -gzip -dc %{SOURCE0} | cpio -imd -mv %{name}/* . && rm -rf %{name} +%setup -q -n %{name} + +# we'll need this later due to -DMKSH_GCC55009 +cat >rtchecks <<'EOF' +typeset -i sari=0 +typeset -Ui uari=0 +typeset -i x=0 +print -r -- $((x++)):$sari=$uari. +let --sari --uari +print -r -- $((x++)):$sari=$uari. +sari=2147483647 uari=2147483647 +print -r -- $((x++)):$sari=$uari. +let ++sari ++uari +print -r -- $((x++)):$sari=$uari. +let --sari --uari +let 'sari *= 2' 'uari *= 2' +let ++sari ++uari +print -r -- $((x++)):$sari=$uari. +let ++sari ++uari +print -r -- $((x++)):$sari=$uari. +sari=-2147483648 uari=-2147483648 +print -r -- $((x++)):$sari=$uari. +let --sari --uari +print -r -- $((x++)):$sari=$uari. +EOF %build -CFLAGS="$RPM_OPT_FLAGS" sh Build.sh -r -c lto +# Work around RHBZ #922974 on Fedora 19 and later +%if 0%{?fedora} >= 19 +CFLAGS="$RPM_OPT_FLAGS -DMKSH_DISABLE_EXPERIMENTAL -DMKSH_GCC55009" sh Build.sh -r +%else +CFLAGS="$RPM_OPT_FLAGS -DMKSH_DISABLE_EXPERIMENTAL -DMKSH_GCC55009" sh Build.sh -r -c lto +%endif +cp test.sh test_mksh.sh +# Work around RHBZ #922974 on Fedora 19 and later +%if 0%{?fedora} >= 19 +CFLAGS="$RPM_OPT_FLAGS -DMKSH_DISABLE_EXPERIMENTAL -DMKSH_GCC55009" sh Build.sh -L -r +%else +CFLAGS="$RPM_OPT_FLAGS -DMKSH_DISABLE_EXPERIMENTAL -DMKSH_GCC55009" sh Build.sh -L -r -c lto +%endif +cp test.sh test_lksh.sh %install rm -rf $RPM_BUILD_ROOT install -D -m 755 %{name} $RPM_BUILD_ROOT%{_bindir}/%{name} +install -D -m 755 lksh $RPM_BUILD_ROOT%{_bindir}/lksh install -D -m 644 %{name}.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{name}.1 +install -D -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_mandir}/man1/lksh.1 install -D -p -m 644 dot.mkshrc $RPM_BUILD_ROOT%{_sysconfdir}/mkshrc install -D -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/skel/.mkshrc %check -echo > test.wait -# Do not run any test requiring openpty(3) until Fedora buildsystem is running -# mock 1.1.12 or better, which should fix the current issue in 1.1.8 (#726271). -# script -qc './test.sh -v; x=$?; rm -f test.wait; exit $x' -script -qc './test.sh -v -C regress:no-ctty; x=$?; rm -f test.wait; exit $x' -maxwait=0 -while test -e test.wait; do - sleep 1 - maxwait=$(expr $maxwait + 1) - test $maxwait -lt 900 || break +./mksh rtchecks >rtchecks.got 2>&1 +if ! cmp --quiet rtchecks.got %{SOURCE3} +then + echo "rtchecks failed" + diff -Naurp %{SOURCE3} rtchecks.got + exit 1 +fi + +for tf in test_mksh.sh test_lksh.sh +do + echo > test.wait + script -qc "./$tf"' -v; x=$?; rm -f test.wait; exit $x' + maxwait=0 + while test -e test.wait; do + sleep 1 + maxwait=$(expr $maxwait + 1) + test $maxwait -lt 900 || break + done done %post @@ -68,11 +112,33 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root,-) %doc dot.mkshrc %{_bindir}/%{name} +%{_bindir}/lksh %config(noreplace) %{_sysconfdir}/mkshrc %config(noreplace) %{_sysconfdir}/skel/.mkshrc %{_mandir}/man1/%{name}.1* +%{_mandir}/man1/lksh.1* %changelog +* Mon Mar 18 2013 Robert Scheck 44-1 +- Upgrade to 44 and work around bug in GCC 4.8 (#922974) + +* Thu Feb 14 2013 Fedora Release Engineering - 41-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Mon Dec 03 2012 Michal Hlavinka - 41-1 +- Upgrade to 41 + +* Fri Jul 20 2012 Michal Hlavinka - 40i-0.20120630 +- Upgrade to pre-release of 40i +- includes new legacy shell lksh for old scripts requiring pdksh or similar old + ksh-88 shell, see man lksh for differences + +* Fri Jul 20 2012 Fedora Release Engineering - 40d-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Fri Jan 13 2012 Fedora Release Engineering - 40d-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + * Sun Dec 11 2011 Robert Scheck 40d-1 - Upgrade to 40d diff --git a/rtchecks.expected b/rtchecks.expected new file mode 100644 index 0000000..0d9a267 --- /dev/null +++ b/rtchecks.expected @@ -0,0 +1,8 @@ +0:0=0. +1:-1=4294967295. +2:2147483647=2147483647. +3:-2147483648=2147483648. +4:-1=4294967295. +5:0=0. +6:-2147483648=2147483648. +7:2147483647=2147483647. diff --git a/sources b/sources index ce4f4e7..2435fac 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -c6428401103367730a95b99284bf47dc mksh-R40d.cpio.gz +fe011686319a8c50d5e237fd5e195fd8 mksh-R44.tgz