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
|
#!/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,
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
# 2011, 2012, 2013, 2014, 2015, 2016, 2017
|
# 2011, 2012, 2013, 2014, 2015, 2016, 2017
|
||||||
@ -495,6 +495,7 @@ check_categories=
|
|||||||
last=
|
last=
|
||||||
tfn=
|
tfn=
|
||||||
legacy=0
|
legacy=0
|
||||||
|
textmode=0
|
||||||
|
|
||||||
for i
|
for i
|
||||||
do
|
do
|
||||||
@ -551,6 +552,12 @@ do
|
|||||||
:-r)
|
:-r)
|
||||||
r=1
|
r=1
|
||||||
;;
|
;;
|
||||||
|
:-T)
|
||||||
|
textmode=1
|
||||||
|
;;
|
||||||
|
:+T)
|
||||||
|
textmode=0
|
||||||
|
;;
|
||||||
:-t)
|
:-t)
|
||||||
last=t
|
last=t
|
||||||
;;
|
;;
|
||||||
@ -596,6 +603,13 @@ else
|
|||||||
add_cppflags -DMKSH_LEGACY_MODE
|
add_cppflags -DMKSH_LEGACY_MODE
|
||||||
fi
|
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
|
if test x"$srcdir" = x"."; then
|
||||||
CPPFLAGS="-I. $CPPFLAGS"
|
CPPFLAGS="-I. $CPPFLAGS"
|
||||||
else
|
else
|
||||||
@ -856,6 +870,28 @@ OS/2)
|
|||||||
add_cppflags -DMKSH_UNEMPLOYED
|
add_cppflags -DMKSH_UNEMPLOYED
|
||||||
add_cppflags -DMKSH_NOPROSPECTOFWORK
|
add_cppflags -DMKSH_NOPROSPECTOFWORK
|
||||||
add_cppflags -DMKSH_NO_LIMITS
|
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)
|
OSF1)
|
||||||
HAVE_SIG_T=0 # incompatible
|
HAVE_SIG_T=0 # incompatible
|
||||||
@ -2364,7 +2400,7 @@ addsrcs '!' HAVE_STRLCPY strlcpy.c
|
|||||||
addsrcs USE_PRINTF_BUILTIN printf.c
|
addsrcs USE_PRINTF_BUILTIN printf.c
|
||||||
test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
|
test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
|
||||||
test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
|
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
|
$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,
|
# 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
|
||||||
@ -57,7 +57,7 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 -DMKSH_DISABLE_DEPRECATED \
|
|||||||
-DHAVE_SETGROUPS=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 \
|
-DHAVE_SETGROUPS=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 \
|
||||||
-DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \
|
-DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \
|
||||||
-DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_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+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U}
|
||||||
CPPFLAGS+= -I.
|
CPPFLAGS+= -I.
|
||||||
COPTS+= -std=c89 -Wall
|
COPTS+= -std=c89 -Wall
|
||||||
@ -100,7 +100,7 @@ regress: ${PROG} check.pl check.t
|
|||||||
echo export FNORD=666 >regress-dir/.mkshrc
|
echo export FNORD=666 >regress-dir/.mkshrc
|
||||||
HOME=$$(realpath regress-dir) perl ${SRCDIR}/check.pl \
|
HOME=$$(realpath regress-dir) perl ${SRCDIR}/check.pl \
|
||||||
-s ${SRCDIR}/check.t -v -p ./${PROG} \
|
-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:= TARGET_OS= CPP=
|
||||||
TEST_BUILD_ENV+= HAVE_STRING_POOLING=0
|
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 -*-
|
# -*- mode: sh -*-
|
||||||
#-
|
#-
|
||||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
@ -36,7 +36,7 @@ description:
|
|||||||
stdin:
|
stdin:
|
||||||
echo $KSH_VERSION
|
echo $KSH_VERSION
|
||||||
name: KSH_VERSION
|
name: KSH_VERSION
|
||||||
category: shell:legacy-no
|
category: !shell:legacy-yes,!shell:textmode-yes
|
||||||
---
|
---
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)LEGACY KSH R54 2017/03/25
|
@(#)LEGACY KSH R54 2017/03/25
|
||||||
@ -45,7 +45,25 @@ description:
|
|||||||
stdin:
|
stdin:
|
||||||
echo $KSH_VERSION
|
echo $KSH_VERSION
|
||||||
name: KSH_VERSION-legacy
|
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
|
name: selftest-1
|
||||||
description:
|
description:
|
||||||
@ -112,7 +130,7 @@ stdin:
|
|||||||
expected-stdout:
|
expected-stdout:
|
||||||
:
|
:
|
||||||
---
|
---
|
||||||
name: selftest-pathsep-os2
|
name: selftest-pathsep-dospath
|
||||||
description:
|
description:
|
||||||
Check that $PATHSEP is set correctly.
|
Check that $PATHSEP is set correctly.
|
||||||
category: os:os2
|
category: os:os2
|
||||||
@ -9423,6 +9441,7 @@ expected-stdout:
|
|||||||
{220->> Bitte keine Werbung einwerfen! <<
|
{220->> Bitte keine Werbung einwerfen! <<
|
||||||
|
|
||||||
}
|
}
|
||||||
|
{220 Who do you wanna pretend to be today?
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
name: print-crlf
|
name: print-crlf
|
||||||
@ -9445,6 +9464,32 @@ expected-stdout:
|
|||||||
print -r -- "{$line}"
|
print -r -- "{$line}"
|
||||||
done
|
done
|
||||||
expected-stdout:
|
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:
|
expected-stdout:
|
||||||
[.4
|
[.4
|
||||||
<bar
|
<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 $
|
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||||
@ -76,7 +76,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: March 19 2017 $
|
.Dd $Mdocdate: April 2 2017 $
|
||||||
.\"
|
.\"
|
||||||
.\" Check which macro package we use, and do other -mdoc setup.
|
.\" 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 utf\-8 7 ,
|
||||||
.Xr mknod 8
|
.Xr mknod 8
|
||||||
.Pp
|
.Pp
|
||||||
.Pa https://www.mirbsd.org/ksh\-chan.htm
|
.Pa http://www.mirbsd.org/ksh\-chan.htm
|
||||||
.Rs
|
.Rs
|
||||||
.%A Morris Bolsky
|
.%A Morris Bolsky
|
||||||
.%B "The KornShell Command and Programming Language"
|
.%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.
|
contributors including our users, to improve the shell is appreciated.
|
||||||
See the documentation, web site and CVS for details.
|
See the documentation, web site and CVS for details.
|
||||||
.Pp
|
.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 BSD daemon is Copyright \(co Marshall Kirk McKusick.
|
||||||
The complete legalese is at:
|
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
|
.\" 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
|
.\" 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
|
.Li PATH=.$PATHSEP$PATH
|
||||||
or add that to a suitable initialisation file.
|
or add that to a suitable initialisation file.
|
||||||
.Pp
|
.Pp
|
||||||
You will have gotten this shell through komh's port on Shellworld
|
There are two different newline modes for mksh-os2: standard (Unix) mode,
|
||||||
most likely. It differs from standard mksh in that ASCII (CR+LF)
|
in which only LF (0A hex) is supported as line separator, and "textmode",
|
||||||
newlines are accepted in many places.
|
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?"
|
.Ss "How do I start mksh on a specific terminal?"
|
||||||
Normally:
|
Normally:
|
||||||
.Dl mksh \-T/dev/tty2
|
.Dl mksh \-T/dev/tty2
|
||||||
|
21
sh.h
21
sh.h
@ -175,7 +175,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#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
|
#endif
|
||||||
#define MKSH_VERSION "R54 2017/03/25"
|
#define MKSH_VERSION "R54 2017/03/25"
|
||||||
|
|
||||||
@ -393,7 +393,6 @@ struct rusage {
|
|||||||
|
|
||||||
#ifdef __OS2__
|
#ifdef __OS2__
|
||||||
#define MKSH_UNIXROOT "/@unixroot"
|
#define MKSH_UNIXROOT "/@unixroot"
|
||||||
#define MKSH_DOSPATH
|
|
||||||
#else
|
#else
|
||||||
#define MKSH_UNIXROOT ""
|
#define MKSH_UNIXROOT ""
|
||||||
#endif
|
#endif
|
||||||
@ -513,12 +512,20 @@ extern int __cdecl setegid(gid_t);
|
|||||||
EXTERN const char *safe_prompt; /* safe prompt if PS1 substitution fails */
|
EXTERN const char *safe_prompt; /* safe prompt if PS1 substitution fails */
|
||||||
|
|
||||||
#ifdef MKSH_LEGACY_MODE
|
#ifdef MKSH_LEGACY_MODE
|
||||||
#define KSH_VERSIONNAME "LEGACY"
|
#define KSH_VERSIONNAME_ISLEGACY "LEGACY"
|
||||||
#else
|
#else
|
||||||
#define KSH_VERSIONNAME "MIRBSD"
|
#define KSH_VERSIONNAME_ISLEGACY "MIRBSD"
|
||||||
#endif
|
#endif
|
||||||
EXTERN const char initvsn[] E_INIT("KSH_VERSION=@(#)" KSH_VERSIONNAME \
|
#ifdef MKSH_WITH_TEXTMODE
|
||||||
" KSH " MKSH_VERSION);
|
#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)
|
#define KSH_VERSION (initvsn + /* "KSH_VERSION=@(#)" */ 16)
|
||||||
|
|
||||||
EXTERN const char digits_uc[] E_INIT("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
EXTERN const char digits_uc[] E_INIT("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||||
@ -586,7 +593,7 @@ char *ucstrstr(char *, const char *);
|
|||||||
#define mkssert(e) do { } while (/* CONSTCOND */ 0)
|
#define mkssert(e) do { } while (/* CONSTCOND */ 0)
|
||||||
#endif
|
#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.
|
#error Must run Build.sh to compile this.
|
||||||
extern void thiswillneverbedefinedIhope(void);
|
extern void thiswillneverbedefinedIhope(void);
|
||||||
int
|
int
|
||||||
|
Reference in New Issue
Block a user