introduce the -T flag to set TEXTMODE (ASCII CR+LF newline support)
This commit is contained in:
40
Build.sh
40
Build.sh
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.710 2017/04/02 13:38:01 tg Exp $'
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.711 2017/04/02 14:14:03 tg Exp $'
|
||||
#-
|
||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012, 2013, 2014, 2015, 2016, 2017
|
||||
@ -495,6 +495,7 @@ check_categories=
|
||||
last=
|
||||
tfn=
|
||||
legacy=0
|
||||
textmode=0
|
||||
|
||||
for i
|
||||
do
|
||||
@ -551,6 +552,12 @@ do
|
||||
:-r)
|
||||
r=1
|
||||
;;
|
||||
:-T)
|
||||
textmode=1
|
||||
;;
|
||||
:+T)
|
||||
textmode=0
|
||||
;;
|
||||
:-t)
|
||||
last=t
|
||||
;;
|
||||
@ -596,6 +603,13 @@ else
|
||||
add_cppflags -DMKSH_LEGACY_MODE
|
||||
fi
|
||||
|
||||
if test $textmode = 0; then
|
||||
check_categories="$check_categories shell:textmode-no shell:binmode-yes"
|
||||
else
|
||||
check_categories="$check_categories shell:textmode-yes shell:binmode-no"
|
||||
add_cppflags -DMKSH_WITH_TEXTMODE
|
||||
fi
|
||||
|
||||
if test x"$srcdir" = x"."; then
|
||||
CPPFLAGS="-I. $CPPFLAGS"
|
||||
else
|
||||
@ -856,6 +870,28 @@ OS/2)
|
||||
add_cppflags -DMKSH_UNEMPLOYED
|
||||
add_cppflags -DMKSH_NOPROSPECTOFWORK
|
||||
add_cppflags -DMKSH_NO_LIMITS
|
||||
add_cppflags -DMKSH_DOSPATH
|
||||
if test $textmode = 0; then
|
||||
x='dis'
|
||||
y='standard OS/2 tools'
|
||||
else
|
||||
x='en'
|
||||
y='standard Unix mksh and other tools'
|
||||
fi
|
||||
echo >&2 "
|
||||
OS/2 Note: mksh can be built with or without 'textmode'.
|
||||
Without 'textmode' it will behave like a standard Unix utility,
|
||||
compatible to mksh on all other platforms, using only ASCII LF
|
||||
(0x0A) as line ending character. This is supported by the mksh
|
||||
upstream developer.
|
||||
With 'textmode', mksh will be modified to behave more like other
|
||||
OS/2 utilities, supporting ASCII CR+LF (0x0D 0x0A) as line ending
|
||||
at the cost of deviation from standard mksh. This is supported by
|
||||
the mksh-os2 porter.
|
||||
|
||||
] You are currently compiling with textmode ${x}abled, introducing
|
||||
] incompatibilities with $y.
|
||||
"
|
||||
;;
|
||||
OSF1)
|
||||
HAVE_SIG_T=0 # incompatible
|
||||
@ -2364,7 +2400,7 @@ addsrcs '!' HAVE_STRLCPY strlcpy.c
|
||||
addsrcs USE_PRINTF_BUILTIN printf.c
|
||||
test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
|
||||
test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
|
||||
add_cppflags -DMKSH_BUILD_R=541
|
||||
add_cppflags -DMKSH_BUILD_R=549
|
||||
|
||||
$e $bi$me: Finished configuration testing, now producing output.$ao
|
||||
|
||||
|
8
Makefile
8
Makefile
@ -1,7 +1,7 @@
|
||||
# $MirOS: src/bin/mksh/Makefile,v 1.155 2016/11/12 00:20:37 tg Exp $
|
||||
# $MirOS: src/bin/mksh/Makefile,v 1.156 2017/04/02 14:14:04 tg Exp $
|
||||
#-
|
||||
# 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>
|
||||
#
|
||||
# Provided that these terms and disclaimer and all copyright notices
|
||||
@ -57,7 +57,7 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 -DMKSH_DISABLE_DEPRECATED \
|
||||
-DHAVE_SETGROUPS=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 \
|
||||
-DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \
|
||||
-DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \
|
||||
-DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=541
|
||||
-DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=549
|
||||
CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U}
|
||||
CPPFLAGS+= -I.
|
||||
COPTS+= -std=c89 -Wall
|
||||
@ -100,7 +100,7 @@ regress: ${PROG} check.pl check.t
|
||||
echo export FNORD=666 >regress-dir/.mkshrc
|
||||
HOME=$$(realpath regress-dir) perl ${SRCDIR}/check.pl \
|
||||
-s ${SRCDIR}/check.t -v -p ./${PROG} \
|
||||
-C shell:legacy-no,int:32,fastbox
|
||||
-C shell:legacy-no,int:32,shell:textmode-no,shell:binmode-yes,fastbox
|
||||
|
||||
TEST_BUILD_ENV:= TARGET_OS= CPP=
|
||||
TEST_BUILD_ENV+= HAVE_STRING_POOLING=0
|
||||
|
53
check.t
53
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.766 2017/03/26 00:10:21 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.767 2017/04/02 14:14:04 tg Exp $
|
||||
# -*- mode: sh -*-
|
||||
#-
|
||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
@ -36,7 +36,7 @@ description:
|
||||
stdin:
|
||||
echo $KSH_VERSION
|
||||
name: KSH_VERSION
|
||||
category: shell:legacy-no
|
||||
category: !shell:legacy-yes,!shell:textmode-yes
|
||||
---
|
||||
expected-stdout:
|
||||
@(#)LEGACY KSH R54 2017/03/25
|
||||
@ -45,7 +45,25 @@ description:
|
||||
stdin:
|
||||
echo $KSH_VERSION
|
||||
name: KSH_VERSION-legacy
|
||||
category: shell:legacy-yes
|
||||
category: !shell:legacy-no,!shell:textmode-yes
|
||||
---
|
||||
expected-stdout:
|
||||
@(#)MIRBSD KSH R54 2017/03/25 +TEXTMODE
|
||||
description:
|
||||
Check version of shell.
|
||||
stdin:
|
||||
echo $KSH_VERSION
|
||||
name: KSH_VERSION-textmode
|
||||
category: !shell:legacy-yes,!shell:textmode-no
|
||||
---
|
||||
expected-stdout:
|
||||
@(#)LEGACY KSH R54 2017/03/25 +TEXTMODE
|
||||
description:
|
||||
Check version of legacy shell.
|
||||
stdin:
|
||||
echo $KSH_VERSION
|
||||
name: KSH_VERSION-legacy-textmode
|
||||
category: !shell:legacy-no,!shell:textmode-no
|
||||
---
|
||||
name: selftest-1
|
||||
description:
|
||||
@ -112,7 +130,7 @@ stdin:
|
||||
expected-stdout:
|
||||
:
|
||||
---
|
||||
name: selftest-pathsep-os2
|
||||
name: selftest-pathsep-dospath
|
||||
description:
|
||||
Check that $PATHSEP is set correctly.
|
||||
category: os:os2
|
||||
@ -9423,6 +9441,7 @@ expected-stdout:
|
||||
{220->> Bitte keine Werbung einwerfen! <<
|
||||
|
||||
}
|
||||
{220 Who do you wanna pretend to be today?
|
||||
}
|
||||
---
|
||||
name: print-crlf
|
||||
@ -9445,6 +9464,32 @@ expected-stdout:
|
||||
print -r -- "{$line}"
|
||||
done
|
||||
expected-stdout:
|
||||
[.5
|
||||
<bar
|
||||
>]
|
||||
{.5}
|
||||
{<bar
|
||||
}
|
||||
---
|
||||
name: print-crlf-textmode
|
||||
description:
|
||||
Check that CR+LF is treated as newline
|
||||
category: shell:textmode-yes
|
||||
stdin:
|
||||
cat >foo <<-'EOF'
|
||||
x='bar
|
||||
' #
|
||||
echo .${#x} #
|
||||
if test x"$KSH_VERSION" = x""; then #
|
||||
printf '<%s>' "$x" #
|
||||
else #
|
||||
print -nr -- "<$x>" #
|
||||
fi #
|
||||
EOF
|
||||
echo "[$("$__progname" foo)]"
|
||||
"$__progname" foo | while IFS= read -r line; do
|
||||
print -r -- "{$line}"
|
||||
done
|
||||
expected-stdout:
|
||||
[.4
|
||||
<bar
|
||||
|
32
mksh.1
32
mksh.1
@ -1,4 +1,4 @@
|
||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.435 2017/03/19 22:31:27 tg Exp $
|
||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.436 2017/04/02 14:14:07 tg Exp $
|
||||
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
|
||||
.\"-
|
||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||
@ -76,7 +76,7 @@
|
||||
.\" with -mandoc, it might implement .Mx itself, but we want to
|
||||
.\" use our own definition. And .Dd must come *first*, always.
|
||||
.\"
|
||||
.Dd $Mdocdate: March 19 2017 $
|
||||
.Dd $Mdocdate: April 2 2017 $
|
||||
.\"
|
||||
.\" Check which macro package we use, and do other -mdoc setup.
|
||||
.\"
|
||||
@ -6455,7 +6455,7 @@ contains the system and suid profile.
|
||||
.Xr utf\-8 7 ,
|
||||
.Xr mknod 8
|
||||
.Pp
|
||||
.Pa https://www.mirbsd.org/ksh\-chan.htm
|
||||
.Pa http://www.mirbsd.org/ksh\-chan.htm
|
||||
.Rs
|
||||
.%A Morris Bolsky
|
||||
.%B "The KornShell Command and Programming Language"
|
||||
@ -6549,9 +6549,17 @@ The effort of several projects, such as Debian and OpenBSD, and other
|
||||
contributors including our users, to improve the shell is appreciated.
|
||||
See the documentation, web site and CVS for details.
|
||||
.Pp
|
||||
.Nm mksh\-os2
|
||||
is developed by
|
||||
.An KO Myung-Hun Aq Mt komh@chollian.net .
|
||||
.Pp
|
||||
.Nm mksh\-w32
|
||||
is developed by
|
||||
.An Michael Langguth Aq Mt lan@scalaris.com .
|
||||
.Pp
|
||||
The BSD daemon is Copyright \(co Marshall Kirk McKusick.
|
||||
The complete legalese is at:
|
||||
.Pa https://www.mirbsd.org/TaC\-mksh.txt
|
||||
.Pa http://www.mirbsd.org/TaC\-mksh.txt
|
||||
.\"
|
||||
.\" This boils down to: feel free to use mksh.ico as application icon
|
||||
.\" or shortcut for mksh or mksh/Win32 or OS/2; distro patches are ok
|
||||
@ -6690,9 +6698,19 @@ not in the search path at all; if you really need this, run the command
|
||||
.Li PATH=.$PATHSEP$PATH
|
||||
or add that to a suitable initialisation file.
|
||||
.Pp
|
||||
You will have gotten this shell through komh's port on Shellworld
|
||||
most likely. It differs from standard mksh in that ASCII (CR+LF)
|
||||
newlines are accepted in many places.
|
||||
There are two different newline modes for mksh-os2: standard (Unix) mode,
|
||||
in which only LF (0A hex) is supported as line separator, and "textmode",
|
||||
which also accepts ASCII newlines (CR+LF), like most other tools on OS/2,
|
||||
but creating an incompatibility with standard
|
||||
.Nm .
|
||||
If you compiled mksh from source, you will get the standard Unix mode unless
|
||||
.Fl T
|
||||
is added during compilation; you will most likely have gotten this shell
|
||||
through komh's port on OS/2World, or from his OS/2 Factory on eComStation
|
||||
Korea, which uses "textmode", though.
|
||||
Most OS/2 users will want to use "textmode" unless they need absolute
|
||||
compatibility with Unix
|
||||
.Nm .
|
||||
.Ss "How do I start mksh on a specific terminal?"
|
||||
Normally:
|
||||
.Dl mksh \-T/dev/tty2
|
||||
|
21
sh.h
21
sh.h
@ -175,7 +175,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.799 2017/04/02 13:08:07 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.800 2017/04/02 14:14:08 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R54 2017/03/25"
|
||||
|
||||
@ -393,7 +393,6 @@ struct rusage {
|
||||
|
||||
#ifdef __OS2__
|
||||
#define MKSH_UNIXROOT "/@unixroot"
|
||||
#define MKSH_DOSPATH
|
||||
#else
|
||||
#define MKSH_UNIXROOT ""
|
||||
#endif
|
||||
@ -513,12 +512,20 @@ extern int __cdecl setegid(gid_t);
|
||||
EXTERN const char *safe_prompt; /* safe prompt if PS1 substitution fails */
|
||||
|
||||
#ifdef MKSH_LEGACY_MODE
|
||||
#define KSH_VERSIONNAME "LEGACY"
|
||||
#define KSH_VERSIONNAME_ISLEGACY "LEGACY"
|
||||
#else
|
||||
#define KSH_VERSIONNAME "MIRBSD"
|
||||
#define KSH_VERSIONNAME_ISLEGACY "MIRBSD"
|
||||
#endif
|
||||
EXTERN const char initvsn[] E_INIT("KSH_VERSION=@(#)" KSH_VERSIONNAME \
|
||||
" KSH " MKSH_VERSION);
|
||||
#ifdef MKSH_WITH_TEXTMODE
|
||||
#define KSH_VERSIONNAME_TEXTMODE " +TEXTMODE"
|
||||
#else
|
||||
#define KSH_VERSIONNAME_TEXTMODE ""
|
||||
#endif
|
||||
#ifndef KSH_VERSIONNAME_VENDOR_EXT
|
||||
#define KSH_VERSIONNAME_VENDOR_EXT ""
|
||||
#endif
|
||||
EXTERN const char initvsn[] E_INIT("KSH_VERSION=@(#)" KSH_VERSIONNAME_ISLEGACY \
|
||||
" KSH " MKSH_VERSION KSH_VERSIONNAME_TEXTMODE KSH_VERSIONNAME_VENDOR_EXT);
|
||||
#define KSH_VERSION (initvsn + /* "KSH_VERSION=@(#)" */ 16)
|
||||
|
||||
EXTERN const char digits_uc[] E_INIT("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
@ -586,7 +593,7 @@ char *ucstrstr(char *, const char *);
|
||||
#define mkssert(e) do { } while (/* CONSTCOND */ 0)
|
||||
#endif
|
||||
|
||||
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 541)
|
||||
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 549)
|
||||
#error Must run Build.sh to compile this.
|
||||
extern void thiswillneverbedefinedIhope(void);
|
||||
int
|
||||
|
Reference in New Issue
Block a user