fixup relation between lksh and mksh (somewhat minimal delta)

This commit is contained in:
tg 2017-02-18 02:33:15 +00:00
parent 18051b7e8a
commit 2584cd0634
9 changed files with 91 additions and 197 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.707 2016/11/11 23:31:29 tg Exp $' srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.708 2017/02/18 02:33:08 tg Exp $'
#- #-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016 # 2011, 2012, 2013, 2014, 2015, 2016
@ -586,11 +586,10 @@ fi
rmf a.exe* a.out* conftest.c conftest.exe* *core core.* ${tfn}* *.bc *.dbg \ rmf a.exe* a.out* conftest.c conftest.exe* *core core.* ${tfn}* *.bc *.dbg \
*.ll *.o *.gen *.cat1 Rebuild.sh lft no signames.inc test.sh x vv.out *.ll *.o *.gen *.cat1 Rebuild.sh lft no signames.inc test.sh x vv.out
SRCS="lalloc.c eval.c exec.c expr.c funcs.c histrap.c jobs.c" SRCS="lalloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c jobs.c"
SRCS="$SRCS lex.c main.c misc.c shf.c syn.c tree.c var.c" SRCS="$SRCS lex.c main.c misc.c shf.c syn.c tree.c var.c"
if test $legacy = 0; then if test $legacy = 0; then
SRCS="$SRCS edit.c"
check_categories="$check_categories shell:legacy-no int:32" check_categories="$check_categories shell:legacy-no int:32"
else else
check_categories="$check_categories shell:legacy-yes" check_categories="$check_categories shell:legacy-yes"

64
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.757 2017/02/17 22:40:09 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.758 2017/02/18 02:33:09 tg Exp $
# -*- mode: sh -*- # -*- mode: sh -*-
#- #-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -30,7 +30,7 @@
# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date # (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R54 2017/02/17 @(#)MIRBSD KSH R54 2017/02/18
description: description:
Check version of shell. Check version of shell.
stdin: stdin:
@ -39,7 +39,7 @@ name: KSH_VERSION
category: shell:legacy-no category: shell:legacy-no
--- ---
expected-stdout: expected-stdout:
@(#)LEGACY KSH R54 2017/02/17 @(#)LEGACY KSH R54 2017/02/18
description: description:
Check version of legacy shell. Check version of legacy shell.
stdin: stdin:
@ -92,23 +92,6 @@ category: disabled
stdin: stdin:
set set
--- ---
name: selftest-legacy
description:
Check some things in the LEGACY KSH
category: shell:legacy-yes
stdin:
set +o emacs
set +o vi
[[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 1=emacs
[[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 1=vi
set -o emacs
set -o vi
[[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 2=emacs
[[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 2=vi
expected-stdout:
2=emacs
2=vi
---
name: selftest-direct-builtin-call name: selftest-direct-builtin-call
description: description:
Check that direct builtin calls work Check that direct builtin calls work
@ -10187,7 +10170,6 @@ name: bashiop-1
description: description:
Check if GNU bash-like I/O redirection works Check if GNU bash-like I/O redirection works
Part 1: this is also supported by GNU bash Part 1: this is also supported by GNU bash
category: shell:legacy-no
stdin: stdin:
exec 3>&1 exec 3>&1
function threeout { function threeout {
@ -10208,7 +10190,6 @@ name: bashiop-2a
description: description:
Check if GNU bash-like I/O redirection works Check if GNU bash-like I/O redirection works
Part 2: this is *not* supported by GNU bash Part 2: this is *not* supported by GNU bash
category: shell:legacy-no
stdin: stdin:
exec 3>&1 exec 3>&1
function threeout { function threeout {
@ -10229,7 +10210,6 @@ name: bashiop-2b
description: description:
Check if GNU bash-like I/O redirection works Check if GNU bash-like I/O redirection works
Part 2: this is *not* supported by GNU bash Part 2: this is *not* supported by GNU bash
category: shell:legacy-no
stdin: stdin:
exec 3>&1 exec 3>&1
function threeout { function threeout {
@ -10250,7 +10230,6 @@ name: bashiop-2c
description: description:
Check if GNU bash-like I/O redirection works Check if GNU bash-like I/O redirection works
Part 2: this is supported by GNU bash 4 only Part 2: this is supported by GNU bash 4 only
category: shell:legacy-no
stdin: stdin:
echo mir >foo echo mir >foo
set -o noclobber set -o noclobber
@ -10274,7 +10253,6 @@ name: bashiop-3a
description: description:
Check if GNU bash-like I/O redirection fails correctly Check if GNU bash-like I/O redirection fails correctly
Part 1: this is also supported by GNU bash Part 1: this is also supported by GNU bash
category: shell:legacy-no
stdin: stdin:
echo mir >foo echo mir >foo
set -o noclobber set -o noclobber
@ -10296,7 +10274,6 @@ name: bashiop-3b
description: description:
Check if GNU bash-like I/O redirection fails correctly Check if GNU bash-like I/O redirection fails correctly
Part 2: this is *not* supported by GNU bash Part 2: this is *not* supported by GNU bash
category: shell:legacy-no
stdin: stdin:
echo mir >foo echo mir >foo
set -o noclobber set -o noclobber
@ -10320,7 +10297,6 @@ description:
Check if GNU bash-like I/O redirection works Check if GNU bash-like I/O redirection works
Part 4: this is also supported by GNU bash, Part 4: this is also supported by GNU bash,
but failed in some mksh versions but failed in some mksh versions
category: shell:legacy-no
stdin: stdin:
exec 3>&1 exec 3>&1
function threeout { function threeout {
@ -10342,11 +10318,10 @@ expected-stdout:
ras ras
dwa dwa
--- ---
name: bashiop-5-normal name: bashiop-5
description: description:
Check if GNU bash-like I/O redirection is only supported Check if GNU bash-like I/O redirection is only supported
in !POSIX !sh mode as it breaks existing scripts' syntax in !POSIX !sh mode as it breaks existing scripts' syntax
category: shell:legacy-no
stdin: stdin:
:>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" . :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
:>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" . :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
@ -10356,20 +10331,6 @@ expected-stdout:
2 = bar . 2 = bar .
3 = bar . 3 = bar .
--- ---
name: bashiop-5-legacy
description:
Check if GNU bash-like I/O redirection is not parsed
in lksh as it breaks existing scripts' syntax
category: shell:legacy-yes
stdin:
:>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
:>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
:>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
expected-stdout:
1 = bar .
2 = bar .
3 = bar .
---
name: oksh-eval name: oksh-eval
description: description:
Check expansions. Check expansions.
@ -10606,7 +10567,6 @@ description:
AT&T ksh93 does this still, which means we must keep it as well AT&T ksh93 does this still, which means we must keep it as well
XXX fails on some old Perl installations XXX fails on some old Perl installations
need-pass: no need-pass: no
category: shell:legacy-no
stdin: stdin:
cat >cld <<-EOF cat >cld <<-EOF
#!$__perlname #!$__perlname
@ -10639,22 +10599,6 @@ stdin:
expected-stdout: expected-stdout:
Fowl Fowl
--- ---
name: fd-cloexec-3
description:
Verify that file descriptors > 2 are not private for LEGACY KSH
category: shell:legacy-yes
stdin:
cat >cld <<-EOF
#!$__perlname
open(my \$fh, ">&", 9) or die "E: open \$!";
syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
EOF
chmod +x cld
exec 9>&1
./cld
expected-stdout:
Fowl
---
name: comsub-1a name: comsub-1a
description: description:
COMSUB are now parsed recursively, so this works COMSUB are now parsed recursively, so this works

View File

@ -1,8 +1,8 @@
# $Id$ # $Id$
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.108 2016/07/26 22:03:41 tg Exp $ # $MirOS: src/bin/mksh/dot.mkshrc,v 1.109 2017/02/18 02:33:11 tg Exp $
#- #-
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, # Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016 # 2011, 2012, 2013, 2014, 2015, 2016, 2017
# mirabilos <m@mirbsd.org> # mirabilos <m@mirbsd.org>
# #
# Provided that these terms and disclaimer and all copyright notices # Provided that these terms and disclaimer and all copyright notices
@ -22,19 +22,56 @@
#- #-
# ${ENV:-~/.mkshrc}: mksh initialisation file for interactive shells # ${ENV:-~/.mkshrc}: mksh initialisation file for interactive shells
# catch non-mksh (including lksh) trying to run this file # catch non-mksh, non-lksh, trying to run this file
case ${KSH_VERSION:-} in case ${KSH_VERSION:-} in
*MIRBSD\ KSH*) ;; *LEGACY\ KSH*|*MIRBSD\ KSH*) ;;
*) return 0 ;; *) return 0 ;;
esac esac
PS1='#'; (( USER_ID )) && PS1='$'; \: "${TERM:=vt100}${HOSTNAME:=$(\ulimit -c \ # give MidnightBSD's laffer1 a bit of csh feeling
0; hostname 2>/dev/null)}${EDITOR:=/bin/ed}${USER:=$(\ulimit -c 0; id -un \ function setenv {
2>/dev/null || \echo \?)}${MKSH:=$(\builtin whence -p mksh)}" if (( $# )); then
HOSTNAME=${HOSTNAME%%*([ ]).*}; HOSTNAME=${HOSTNAME##*([ ])} \eval '\export "$1"="${2:-}"'
[[ $HOSTNAME = ?(ip6-)localhost?(6) ]] && HOSTNAME= else
\: "${HOSTNAME:=nil}${MKSH:=/bin/mksh}"; \export EDITOR HOSTNAME MKSH TERM USER \typeset -x
PS4='[$EPOCHREALTIME] '; PS1=$'\001\r''${| fi
}
# pager (not control character safe)
smores() (
\set +m
\cat "$@" |&
\trap "rv=\$?; 'kill' $! >/dev/null 2>&1; 'exit' \$rv" EXIT
while IFS= \read -pr line; do
llen=${%line}
(( llen == -1 )) && llen=${#line}
(( llen = llen ? (llen + COLUMNS - 1) / COLUMNS : 1 ))
if (( (curlin += llen) >= LINES )); then
\builtin print -n -- '\e[7m--more--\e[0m'
\read -u1 || \exit $?
[[ $REPLY = [Qq]* ]] && \exit 0
curlin=$llen
fi
\builtin print -r -- "$line"
done
)
\: "${EDITOR:=/bin/ed}${TERM:=vt100}${HOSTNAME:=$(\ulimit -c 0; \echo \
$(hostname 2>/dev/null))}${USER:=$(\ulimit -c 0; id -un 2>/dev/null)}"
[[ $HOSTNAME = ?(?(ip6-)localhost?(6)) ]] && HOSTNAME=nil; \: "${USER:=?}"
\alias ls=ls l='ls -F' la='l -a' ll='l -l' lo='l -alo'; \unalias ls
\export EDITOR HOSTNAME TERM USER
# minimal support for lksh users
if [[ $KSH_VERSION = *LEGACY\ KSH* ]]; then
PS1='$USER@${HOSTNAME%%.*}:$PWD>'
return 0
fi
# mksh-specific from here
\: "${MKSH:=$(\builtin whence -p mksh)}"; \: "${MKSH:=/bin/mksh}"; \export MKSH
PS4='[$EPOCHREALTIME] '; PS1='#'; (( USER_ID )) && PS1='$'; PS1=$'\001\r''${|
\typeset e=$? \typeset e=$?
(( e )) && REPLY+="$e|" (( e )) && REPLY+="$e|"
@ -47,12 +84,6 @@ PS4='[$EPOCHREALTIME] '; PS1=$'\001\r''${|
\return $e \return $e
} '"$PS1 " } '"$PS1 "
\alias ls=ls
\unalias ls
\alias l='ls -F'
\alias la='l -a'
\alias ll='l -l'
\alias lo='l -alo'
\alias doch='sudo mksh -c "$(\builtin fc -ln -1)"' \alias doch='sudo mksh -c "$(\builtin fc -ln -1)"'
\command -v rot13 >/dev/null || \alias rot13='tr \ \command -v rot13 >/dev/null || \alias rot13='tr \
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \
@ -249,25 +280,6 @@ function pushd {
\dirs $fa \dirs $fa
} }
# pager (not control character safe)
smores() (
\set +m
\cat "$@" |&
\trap "rv=\$?; 'kill' $! >/dev/null 2>&1; 'exit' \$rv" EXIT
while IFS= \read -pr line; do
llen=${%line}
(( llen == -1 )) && llen=${#line}
(( llen = llen ? (llen + COLUMNS - 1) / COLUMNS : 1 ))
if (( (curlin += llen) >= LINES )); then
\builtin print -n -- '\e[7m--more--\e[0m'
\read -u1 || \exit $?
[[ $REPLY = [Qq]* ]] && \exit 0
curlin=$llen
fi
\builtin print -r -- "$line"
done
)
# base64 encoder and decoder, RFC compliant, NUL safe, not EBCDIC safe # base64 encoder and decoder, RFC compliant, NUL safe, not EBCDIC safe
function Lb64decode { function Lb64decode {
\set +U \set +U
@ -380,15 +392,6 @@ function Lstripcom {
done done
} }
# give MidnightBSD's laffer1 a bit of csh feeling
function setenv {
if (( $# )); then
\eval '\export "$1"="${2:-}"'
else
\typeset -x
fi
}
# toggle built-in aliases and utilities, and aliases and functions from mkshrc # toggle built-in aliases and utilities, and aliases and functions from mkshrc
function enable { function enable {
\typeset doprnt=0 mode=1 x y z rv=0 \typeset doprnt=0 mode=1 x y z rv=0

View File

@ -38,7 +38,7 @@
#endif #endif
#endif #endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.322 2017/02/18 01:27:24 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.323 2017/02/18 02:33:11 tg Exp $");
#if HAVE_KILLPG #if HAVE_KILLPG
/* /*
@ -2809,7 +2809,6 @@ c_exec(const char **wp MKSH_A_UNUSED)
for (i = 0; i < NUFILE; i++) { for (i = 0; i < NUFILE; i++) {
if (e->savefd[i] > 0) if (e->savefd[i] > 0)
close(e->savefd[i]); close(e->savefd[i]);
#ifndef MKSH_LEGACY_MODE
/* /*
* keep all file descriptors > 2 private for ksh, * keep all file descriptors > 2 private for ksh,
* but not for POSIX or legacy/kludge sh * but not for POSIX or legacy/kludge sh
@ -2817,7 +2816,6 @@ c_exec(const char **wp MKSH_A_UNUSED)
if (!Flag(FPOSIX) && !Flag(FSH) && i > 2 && if (!Flag(FPOSIX) && !Flag(FSH) && i > 2 &&
e->savefd[i]) e->savefd[i])
fcntl(i, F_SETFD, FD_CLOEXEC); fcntl(i, F_SETFD, FD_CLOEXEC);
#endif
} }
e->savefd = NULL; e->savefd = NULL;
} }

6
lex.c
View File

@ -2,7 +2,7 @@
/*- /*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015, 2016 * 2011, 2012, 2013, 2014, 2015, 2016, 2017
* mirabilos <m@mirbsd.org> * mirabilos <m@mirbsd.org>
* *
* Provided that these terms and disclaimer and all copyright notices * Provided that these terms and disclaimer and all copyright notices
@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.228 2016/08/01 21:38:03 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.229 2017/02/18 02:33:12 tg Exp $");
/* /*
* states while lexing word * states while lexing word
@ -893,9 +893,7 @@ yylex(int cf)
dp = Xstring(ws, wp); dp = Xstring(ws, wp);
if (state == SBASE && ( if (state == SBASE && (
#ifndef MKSH_LEGACY_MODE
(c == '&' && !Flag(FSH) && !Flag(FPOSIX)) || (c == '&' && !Flag(FSH) && !Flag(FPOSIX)) ||
#endif
c == '<' || c == '>') && ((c2 = Xlength(ws, wp)) == 0 || c == '<' || c == '>') && ((c2 = Xlength(ws, wp)) == 0 ||
(c2 == 2 && dp[0] == CHAR && ksh_isdigit(dp[1])))) { (c2 == 2 && dp[0] == CHAR && ksh_isdigit(dp[1])))) {
struct ioword *iop = alloc(sizeof(struct ioword), ATEMP); struct ioword *iop = alloc(sizeof(struct ioword), ATEMP);

78
lksh.1
View File

@ -1,6 +1,6 @@
.\" $MirOS: src/bin/mksh/lksh.1,v 1.20 2016/11/11 23:31:35 tg Exp $ .\" $MirOS: src/bin/mksh/lksh.1,v 1.21 2017/02/18 02:33:13 tg Exp $
.\"- .\"-
.\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015, 2016 .\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015, 2016, 2017
.\" mirabilos <m@mirbsd.org> .\" mirabilos <m@mirbsd.org>
.\" .\"
.\" Provided that these terms and disclaimer and all copyright notices .\" Provided that these terms and disclaimer and all copyright notices
@ -74,7 +74,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to .\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always. .\" use our own definition. And .Dd must come *first*, always.
.\" .\"
.Dd $Mdocdate: November 11 2016 $ .Dd $Mdocdate: February 18 2017 $
.\" .\"
.\" Check which macro package we use, and do other -mdoc setup. .\" Check which macro package we use, and do other -mdoc setup.
.\" .\"
@ -173,9 +173,15 @@ It is built on
refer to its manual page for details on the scripting language. refer to its manual page for details on the scripting language.
It is recommended to port scripts to It is recommended to port scripts to
.Nm mksh .Nm mksh
instead of relying on legacy or idiotic POSIX-mandated behaviour, instead of relying on legacy or objectionable POSIX-mandated behaviour,
since the MirBSD Korn Shell scripting language is much more consistent. since the MirBSD Korn Shell scripting language is much more consistent.
.Pp .Pp
Do not use
.Nm
as an interactive or login shell; use
.Nm mksh
instead.
.Pp
Note that it's strongly recommended to invoke Note that it's strongly recommended to invoke
.Nm .Nm
with at least the with at least the
@ -195,15 +201,6 @@ currently has the following differences from
.Nm mksh : .Nm mksh :
.Bl -bullet .Bl -bullet
.It .It
.\"XXX TODO: remove (some systems may wish to have lksh as ksh)
There is no explicit support for interactive use,
nor any command line editing or history code.
Hence,
.Nm
is not suitable as a user's login shell, either; use
.Nm mksh
instead.
.It
The The
.Ev KSH_VERSION .Ev KSH_VERSION
string identifies string identifies
@ -241,25 +238,11 @@ Division of the largest negative number by \-1 is Undefined Behaviour.
The compiler is permitted to delete all data and crash the system The compiler is permitted to delete all data and crash the system
if Undefined Behaviour occurs (see above for an example). if Undefined Behaviour occurs (see above for an example).
.It .It
.\"XXX TODO: move this to FPOSIX
The rotation arithmetic operators are not available. The rotation arithmetic operators are not available.
.It .It
The shift arithmetic operators take all bits of the second operand into The shift arithmetic operators take all bits of the second operand into
account; if they exceed permitted precision, the result is unspecified. account; if they exceed permitted precision, the result is unspecified.
.It .It
.\"XXX TODO: move this to FPOSIX
The
.Tn GNU
.Nm bash
extension &\*(Gt to redirect stdout and stderr in one go is not parsed.
.It
.\"XXX TODO: drop along with allowing interactivity
The
.Nm mksh
command line option
.Fl T
is not available.
.It
Unless Unless
.Ic set -o posix .Ic set -o posix
is active, is active,
@ -275,24 +258,13 @@ passes through the errorlevel from the
.Xr getopt 1 .Xr getopt 1
command. command.
.It .It
.\"XXX TODO: move to FPOSIX/FSH
Unlike
.At
.Nm ksh ,
.Nm mksh
in
.Fl o Ic posix
or
.Fl o Ic sh
mode and
.Nm lksh
do not keep file descriptors \*(Gt 2 private from sub-processes.
.It
Functions defined with the Functions defined with the
.Ic function .Ic function
reserved word share the shell options reserved word share the shell options
.Pq Ic set -o .Pq Ic set -o
instead of locally scoping them. instead of locally scoping them.
.It
Support for persistent history is never compiled in.
.El .El
.Sh SEE ALSO .Sh SEE ALSO
.Xr mksh 1 .Xr mksh 1
@ -301,12 +273,6 @@ instead of locally scoping them.
.Pp .Pp
.Pa https://www.mirbsd.org/ksh\-chan.htm .Pa https://www.mirbsd.org/ksh\-chan.htm
.Sh CAVEATS .Sh CAVEATS
The distinction between the shell variants
.Pq Nm lksh / Nm mksh
and shell flags
.Pq Fl o Ic posix / Ic sh
will be reworked for an upcoming release.
.Pp
To use To use
.Nm .Nm
as as
@ -315,16 +281,22 @@ compilation to enable
.Ic set -o posix .Ic set -o posix
by default if called as by default if called as
.Nm sh .Nm sh
.Pq adding Dv \-DMKSH_BINSHPOSIX to Dv CPPFLAGS
is highly recommended for better standards compliance. is highly recommended for better standards compliance.
.Pp
For better compatibility with legacy scripts, such as many For better compatibility with legacy scripts, such as many
.Tn Debian .Tn Debian
maintainer scripts, Upstart and SYSV init scripts, and other maintainer scripts, Upstart and SYSV init scripts, and other
unfixed scripts, using the compile-time options for enabling unfixed scripts, also adding the
.Dv \-DMKSH_BINSHREDUCED
compile-time option to enable
.Em both .Em both
.Ic set -o posix -o sh .Ic set -o posix -o sh
when the shell is run as when the shell is run as
.Nm sh .Nm sh ,
is recommended. as well as integrating the optional disrecommended
.Xr printf 1
builtin, might be necessary.
.Pp .Pp
.Nm .Nm
tries to make a cross between a legacy bourne/posix compatibl-ish tries to make a cross between a legacy bourne/posix compatibl-ish
@ -332,14 +304,6 @@ shell and a legacy pdksh-alike but
.Dq legacy .Dq legacy
is not exactly specified. is not exactly specified.
.Pp .Pp
The
.Ic set
built-in command does not currently have all options one would expect
from a full-blown
.Nm mksh
or
.Nm pdksh .
.Pp
Talk to the Talk to the
.Mx .Mx
development team using the mailing list at development team using the mailing list at

8
misc.c
View File

@ -3,7 +3,7 @@
/*- /*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015, 2016 * 2011, 2012, 2013, 2014, 2015, 2016, 2017
* mirabilos <m@mirbsd.org> * mirabilos <m@mirbsd.org>
* *
* Provided that these terms and disclaimer and all copyright notices * Provided that these terms and disclaimer and all copyright notices
@ -30,7 +30,7 @@
#include <grp.h> #include <grp.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.250 2016/11/12 03:54:48 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.251 2017/02/18 02:33:13 tg Exp $");
#define KSH_CHVT_FLAG #define KSH_CHVT_FLAG
#ifdef MKSH_SMALL #ifdef MKSH_SMALL
@ -40,10 +40,6 @@ __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.250 2016/11/12 03:54:48 tg Exp $");
#define KSH_CHVT_CODE #define KSH_CHVT_CODE
#define KSH_CHVT_FLAG #define KSH_CHVT_FLAG
#endif #endif
#ifdef MKSH_LEGACY_MODE
#undef KSH_CHVT_CODE
#undef KSH_CHVT_FLAG
#endif
/* type bits for unsigned char */ /* type bits for unsigned char */
unsigned char chtypes[UCHAR_MAX + 1]; unsigned char chtypes[UCHAR_MAX + 1];

14
sh.h
View File

@ -10,7 +10,7 @@
/*- /*-
* Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, * Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015, 2016 * 2011, 2012, 2013, 2014, 2015, 2016, 2017
* mirabilos <m@mirbsd.org> * mirabilos <m@mirbsd.org>
* *
* Provided that these terms and disclaimer and all copyright notices * Provided that these terms and disclaimer and all copyright notices
@ -175,9 +175,9 @@
#endif #endif
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.792 2017/02/17 22:40:13 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.793 2017/02/18 02:33:14 tg Exp $");
#endif #endif
#define MKSH_VERSION "R54 2017/02/17" #define MKSH_VERSION "R54 2017/02/18"
/* arithmetic types: C implementation */ /* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES #if !HAVE_CAN_INTTYPES
@ -630,14 +630,6 @@ im_sorry_dave(void)
} while (/* CONSTCOND */ 0) } while (/* CONSTCOND */ 0)
#endif #endif
#ifdef MKSH_LEGACY_MODE
#ifndef MKSH_NO_CMDLINE_EDITING
#define MKSH_NO_CMDLINE_EDITING /* defined */
#endif
#undef MKSH_S_NOVI
#define MKSH_S_NOVI 1
#endif
#ifdef MKSH_SMALL #ifdef MKSH_SMALL
#ifndef MKSH_NOPWNAM #ifndef MKSH_NOPWNAM
#define MKSH_NOPWNAM /* defined */ #define MKSH_NOPWNAM /* defined */

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2013, 2014, 2015 * Copyright (c) 2013, 2014, 2015, 2017
* mirabilos <m@mirbsd.org> * mirabilos <m@mirbsd.org>
* *
* Provided that these terms and disclaimer and all copyright notices * Provided that these terms and disclaimer and all copyright notices
@ -19,7 +19,7 @@
*/ */
@SHFLAGS_DEFNS @SHFLAGS_DEFNS
__RCSID("$MirOS: src/bin/mksh/sh_flags.opt,v 1.4 2015/12/12 21:08:44 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh_flags.opt,v 1.5 2017/02/18 02:33:15 tg Exp $");
@SHFLAGS_ENUMS @SHFLAGS_ENUMS
#define FN(sname,cname,flags,ochar) cname, #define FN(sname,cname,flags,ochar) cname,
#define F0(sname,cname,flags,ochar) cname = 0, #define F0(sname,cname,flags,ochar) cname = 0,
@ -52,7 +52,7 @@ FN("bgnice", FBGNICE, OF_ANY
FN("braceexpand", FBRACEEXPAND, OF_ANY FN("braceexpand", FBRACEEXPAND, OF_ANY
/* ./. Emacs command line editing mode */ /* ./. Emacs command line editing mode */
>|!defined(MKSH_NO_CMDLINE_EDITING) || defined(MKSH_LEGACY_MODE) >|!MKSH_NO_CMDLINE_EDITING
FN("emacs", FEMACS, OF_ANY FN("emacs", FEMACS, OF_ANY
/* -e quit on error */ /* -e quit on error */
@ -60,7 +60,7 @@ FN("emacs", FEMACS, OF_ANY
FN("errexit", FERREXIT, OF_ANY FN("errexit", FERREXIT, OF_ANY
/* ./. Emacs command line editing mode, gmacs variant */ /* ./. Emacs command line editing mode, gmacs variant */
>|!defined(MKSH_NO_CMDLINE_EDITING) || defined(MKSH_LEGACY_MODE) >|!MKSH_NO_CMDLINE_EDITING
FN("gmacs", FGMACS, OF_ANY FN("gmacs", FGMACS, OF_ANY
/* ./. reading EOF does not exit */ /* ./. reading EOF does not exit */
@ -160,19 +160,19 @@ FN("utf8-mode", FUNICODE, OF_ANY
FN("verbose", FVERBOSE, OF_ANY FN("verbose", FVERBOSE, OF_ANY
/* ./. Vi command line editing mode */ /* ./. Vi command line editing mode */
>|!defined(MKSH_NO_CMDLINE_EDITING) || defined(MKSH_LEGACY_MODE) >|!MKSH_NO_CMDLINE_EDITING
FN("vi", FVI, OF_ANY FN("vi", FVI, OF_ANY
/* ./. enable ESC as file name completion character (non-standard) */ /* ./. enable ESC as file name completion character (non-standard) */
>|!defined(MKSH_NO_CMDLINE_EDITING) || defined(MKSH_LEGACY_MODE) >|!MKSH_NO_CMDLINE_EDITING
FN("vi-esccomplete", FVIESCCOMPLETE, OF_ANY FN("vi-esccomplete", FVIESCCOMPLETE, OF_ANY
/* ./. enable Tab as file name completion character (non-standard) */ /* ./. enable Tab as file name completion character (non-standard) */
>|!defined(MKSH_NO_CMDLINE_EDITING) || defined(MKSH_LEGACY_MODE) >|!MKSH_NO_CMDLINE_EDITING
FN("vi-tabcomplete", FVITABCOMPLETE, OF_ANY FN("vi-tabcomplete", FVITABCOMPLETE, OF_ANY
/* ./. always read in raw mode (no effect) */ /* ./. always read in raw mode (no effect) */
>|!defined(MKSH_NO_CMDLINE_EDITING) || defined(MKSH_LEGACY_MODE) >|!MKSH_NO_CMDLINE_EDITING
FN("viraw", FVIRAW, OF_ANY FN("viraw", FVIRAW, OF_ANY
/* -x execution trace (display commands as they are run) */ /* -x execution trace (display commands as they are run) */