remove fd>9 support in favour of upcoming named file descriptors; bump
This commit is contained in:
parent
5edb355336
commit
f9d131133e
26
Build.sh
26
Build.sh
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.699 2016/07/25 00:04:35 tg Exp $'
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.700 2016/07/25 21:05:18 tg Exp $'
|
||||
#-
|
||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012, 2013, 2014, 2015, 2016
|
||||
|
@ -596,7 +596,6 @@ else
|
|||
check_categories="$check_categories shell:legacy-yes"
|
||||
add_cppflags -DMKSH_LEGACY_MODE
|
||||
HAVE_PERSISTENT_HISTORY=0
|
||||
HAVE_ISSET_MKSH_CONSERVATIVE_FDS=1 # from sh.h
|
||||
fi
|
||||
|
||||
if test x"$srcdir" = x"."; then
|
||||
|
@ -691,7 +690,6 @@ case $TARGET_OS in
|
|||
: "${HAVE_CAN_OTWO=0}"
|
||||
add_cppflags -DMKSH_NO_SIGSETJMP
|
||||
add_cppflags -DMKSH_TYPEDEF_SIG_ATOMIC_T=int
|
||||
add_cppflags -DMKSH_CONSERVATIVE_FDS
|
||||
;;
|
||||
AIX)
|
||||
add_cppflags -D_ALL_SOURCE
|
||||
|
@ -721,7 +719,6 @@ Coherent)
|
|||
add_cppflags -DMKSH__NO_SYMLINK
|
||||
check_categories="$check_categories nosymlink"
|
||||
add_cppflags -DMKSH__NO_SETEUGID
|
||||
add_cppflags -DMKSH_CONSERVATIVE_FDS
|
||||
add_cppflags -DMKSH_DISABLE_TTY_WARNING
|
||||
;;
|
||||
CYGWIN*)
|
||||
|
@ -737,7 +734,6 @@ FreeBSD)
|
|||
FreeMiNT)
|
||||
oswarn="; it has minor issues"
|
||||
add_cppflags -D_GNU_SOURCE
|
||||
add_cppflags -DMKSH_CONSERVATIVE_FDS
|
||||
: "${HAVE_SETLOCALE_CTYPE=0}"
|
||||
;;
|
||||
GNU)
|
||||
|
@ -787,14 +783,12 @@ MidnightBSD)
|
|||
Minix-vmd)
|
||||
add_cppflags -DMKSH__NO_SETEUGID
|
||||
add_cppflags -DMKSH_UNEMPLOYED
|
||||
add_cppflags -DMKSH_CONSERVATIVE_FDS
|
||||
add_cppflags -D_MINIX_SOURCE
|
||||
oldish_ed=no-stderr-ed # no /bin/ed, maybe see below
|
||||
: "${HAVE_SETLOCALE_CTYPE=0}"
|
||||
;;
|
||||
Minix3)
|
||||
add_cppflags -DMKSH_UNEMPLOYED
|
||||
add_cppflags -DMKSH_CONSERVATIVE_FDS
|
||||
add_cppflags -DMKSH_NO_LIMITS
|
||||
add_cppflags -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2 -D_MINIX
|
||||
oldish_ed=no-stderr-ed # /usr/bin/ed(!) is broken
|
||||
|
@ -825,12 +819,10 @@ NEXTSTEP)
|
|||
oswarn="; it needs libposix.a"
|
||||
;;
|
||||
esac
|
||||
add_cppflags -DMKSH_CONSERVATIVE_FDS
|
||||
;;
|
||||
Ninix3)
|
||||
# similar to Minix3
|
||||
add_cppflags -DMKSH_UNEMPLOYED
|
||||
add_cppflags -DMKSH_CONSERVATIVE_FDS
|
||||
add_cppflags -DMKSH_NO_LIMITS
|
||||
# but no idea what else could be needed
|
||||
oswarn="; it has unknown issues"
|
||||
|
@ -898,7 +890,6 @@ SCO_SV)
|
|||
oswarn="$oswarn$nl$TARGET_OS ${TARGET_OSREV}, please tell me what to do"
|
||||
;;
|
||||
esac
|
||||
add_cppflags -DMKSH_CONSERVATIVE_FDS
|
||||
: "${HAVE_SYS_SIGLIST=0}${HAVE__SYS_SIGLIST=0}"
|
||||
;;
|
||||
skyos)
|
||||
|
@ -916,12 +907,10 @@ syllable)
|
|||
ULTRIX)
|
||||
: "${CC=cc -YPOSIX}"
|
||||
add_cppflags -DMKSH_TYPEDEF_SSIZE_T=int
|
||||
add_cppflags -DMKSH_CONSERVATIVE_FDS
|
||||
: "${HAVE_SETLOCALE_CTYPE=0}"
|
||||
;;
|
||||
UnixWare|UNIX_SV)
|
||||
# SCO UnixWare
|
||||
add_cppflags -DMKSH_CONSERVATIVE_FDS
|
||||
: "${HAVE_SYS_SIGLIST=0}${HAVE__SYS_SIGLIST=0}"
|
||||
;;
|
||||
UWIN*)
|
||||
|
@ -1536,7 +1525,7 @@ i1) fv=1 ;;
|
|||
i2) fv=2; fx=' (on demand)' ;;
|
||||
esac
|
||||
ac_testdone
|
||||
ac_cppflags
|
||||
test x"$HAVE_STRING_POOLING" = x"0" || ac_cppflags
|
||||
|
||||
phase=x
|
||||
# The following tests run with -Werror or similar (all compilers) if possible
|
||||
|
@ -1645,7 +1634,6 @@ if ac_ifcpp 'ifdef MKSH_SMALL' isset_MKSH_SMALL '' \
|
|||
: "${HAVE_NICE=0}"
|
||||
: "${HAVE_PERSISTENT_HISTORY=0}"
|
||||
check_categories="$check_categories smksh"
|
||||
HAVE_ISSET_MKSH_CONSERVATIVE_FDS=1 # from sh.h
|
||||
fi
|
||||
ac_ifcpp 'if defined(MKSH_BINSHPOSIX) || defined(MKSH_BINSHREDUCED)' \
|
||||
isset_MKSH_BINSH '' 'if invoking as sh should be handled specially' && \
|
||||
|
@ -1658,12 +1646,6 @@ ac_ifcpp 'ifdef MKSH_NOPROSPECTOFWORK' isset_MKSH_NOPROSPECTOFWORK '' \
|
|||
check_categories="$check_categories arge nojsig"
|
||||
ac_ifcpp 'ifdef MKSH_ASSUME_UTF8' isset_MKSH_ASSUME_UTF8 '' \
|
||||
'if the default UTF-8 mode is specified' && : "${HAVE_SETLOCALE_CTYPE=0}"
|
||||
if ac_ifcpp 'ifdef MKSH_CONSERVATIVE_FDS' isset_MKSH_CONSERVATIVE_FDS '' \
|
||||
'if traditional/conservative fd use is requested'; then
|
||||
check_categories="$check_categories convfds"
|
||||
else
|
||||
echo >&2 "WARNING: not building with -DMKSH_CONSERVATIVE_FDS is deprecated"
|
||||
fi
|
||||
#ac_ifcpp 'ifdef MKSH_DISABLE_DEPRECATED' isset_MKSH_DISABLE_DEPRECATED '' \
|
||||
# "if deprecated features are to be omitted" && \
|
||||
# check_categories="$check_categories nodeprecated"
|
||||
|
@ -2360,7 +2342,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=523
|
||||
add_cppflags -DMKSH_BUILD_R=529
|
||||
|
||||
$e $bi$me: Finished configuration testing, now producing output.$ao
|
||||
|
||||
|
@ -2666,9 +2648,7 @@ MKSH_A4PB force use of arc4random_pushb
|
|||
MKSH_ASSUME_UTF8 (0=disabled, 1=enabled; default: unset)
|
||||
MKSH_BINSHPOSIX if */sh or */-sh, enable set -o posix
|
||||
MKSH_BINSHREDUCED if */sh or */-sh, enable set -o sh
|
||||
MKSH_CLRTOEOL_STRING "\033[K"
|
||||
MKSH_CLS_STRING "\033[;H\033[J"
|
||||
MKSH_CONSERVATIVE_FDS fd 0-9 for scripts, shell only up to 31 (soon default)
|
||||
MKSH_DEFAULT_EXECSHELL "/bin/sh" (do not change)
|
||||
MKSH_DEFAULT_PROFILEDIR "/etc" (do not change)
|
||||
MKSH_DEFAULT_TMPDIR "/tmp" (do not change)
|
||||
|
|
9
Makefile
9
Makefile
|
@ -1,4 +1,4 @@
|
|||
# $MirOS: src/bin/mksh/Makefile,v 1.149 2016/07/25 00:04:37 tg Exp $
|
||||
# $MirOS: src/bin/mksh/Makefile,v 1.150 2016/07/25 21:05:19 tg Exp $
|
||||
#-
|
||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012, 2013, 2014, 2015, 2016
|
||||
|
@ -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=523
|
||||
-DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=529
|
||||
CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U}
|
||||
CPPFLAGS+= -I.
|
||||
COPTS+= -std=c89 -Wall
|
||||
|
@ -102,6 +102,9 @@ regress: ${PROG} check.pl check.t
|
|||
-s ${SRCDIR}/check.t -v -p ./${PROG} \
|
||||
-C shell:legacy-no,int:32,fastbox
|
||||
|
||||
TEST_BUILD_ENV:= TARGET_OS= CPP=
|
||||
TEST_BUILD_ENV+= HAVE_STRING_POOLING=0
|
||||
|
||||
test-build: .PHONY
|
||||
-rm -rf build-dir
|
||||
mkdir -p build-dir
|
||||
|
@ -110,7 +113,7 @@ test-build: .PHONY
|
|||
.endif
|
||||
cd build-dir; env CC=${CC:Q} CFLAGS=${CFLAGS:M*:Q} \
|
||||
CPPFLAGS=${CPPFLAGS:M*:Q} LDFLAGS=${LDFLAGS:M*:Q} \
|
||||
LIBS= NOWARN=-Wno-error TARGET_OS= CPP= /bin/sh \
|
||||
LIBS= NOWARN=-Wno-error ${TEST_BUILD_ENV} /bin/sh \
|
||||
${SRCDIR}/Build.sh -Q -r ${_TBF} && ./test.sh -v -f
|
||||
|
||||
CLEANFILES+= lksh.cat1
|
||||
|
|
29
check.t
29
check.t
|
@ -1,4 +1,4 @@
|
|||
# $MirOS: src/bin/mksh/check.t,v 1.743 2016/07/25 20:38:00 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.744 2016/07/25 21:05:19 tg Exp $
|
||||
# -*- mode: sh -*-
|
||||
#-
|
||||
# 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
|
||||
|
||||
expected-stdout:
|
||||
@(#)MIRBSD KSH R52 2016/07/24
|
||||
@(#)MIRBSD KSH R53 2016/07/25
|
||||
description:
|
||||
Check version of shell.
|
||||
stdin:
|
||||
|
@ -39,7 +39,7 @@ name: KSH_VERSION
|
|||
category: shell:legacy-no
|
||||
---
|
||||
expected-stdout:
|
||||
@(#)LEGACY KSH R52 2016/07/24
|
||||
@(#)LEGACY KSH R53 2016/07/25
|
||||
description:
|
||||
Check version of legacy shell.
|
||||
stdin:
|
||||
|
@ -10138,29 +10138,6 @@ expected-stdout:
|
|||
2 = bar .
|
||||
3 = bar .
|
||||
---
|
||||
name: mkshiop-1
|
||||
description:
|
||||
Check for support of more than 9 file descriptors
|
||||
category: !convfds
|
||||
stdin:
|
||||
read -u10 foo 10<<< bar
|
||||
echo x$foo
|
||||
expected-stdout:
|
||||
xbar
|
||||
---
|
||||
name: mkshiop-2
|
||||
description:
|
||||
Check for support of more than 9 file descriptors
|
||||
category: !convfds
|
||||
stdin:
|
||||
exec 12>foo
|
||||
print -u12 bar
|
||||
echo baz >&12
|
||||
cat foo
|
||||
expected-stdout:
|
||||
bar
|
||||
baz
|
||||
---
|
||||
name: oksh-eval
|
||||
description:
|
||||
Check expansions.
|
||||
|
|
17
lex.c
17
lex.c
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.226 2016/07/25 00:04:44 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.227 2016/07/25 21:05:21 tg Exp $");
|
||||
|
||||
/*
|
||||
* states while lexing word
|
||||
|
@ -887,20 +887,11 @@ yylex(int cf)
|
|||
#ifndef MKSH_LEGACY_MODE
|
||||
(c == '&' && !Flag(FSH) && !Flag(FPOSIX)) ||
|
||||
#endif
|
||||
c == '<' || c == '>')) {
|
||||
c == '<' || c == '>') && ((c2 = Xlength(ws, wp)) == 0 ||
|
||||
(c2 == 2 && dp[0] == CHAR && ksh_isdigit(dp[1])))) {
|
||||
struct ioword *iop = alloc(sizeof(struct ioword), ATEMP);
|
||||
|
||||
if (Xlength(ws, wp) == 0)
|
||||
iop->unit = c == '<' ? 0 : 1;
|
||||
else for (iop->unit = 0, c2 = 0; c2 < Xlength(ws, wp); c2 += 2) {
|
||||
if (dp[c2] != CHAR)
|
||||
goto no_iop;
|
||||
if (!ksh_isdigit(dp[c2 + 1]))
|
||||
goto no_iop;
|
||||
iop->unit = iop->unit * 10 + ksh_numdig(dp[c2 + 1]);
|
||||
if (iop->unit >= FDBASE)
|
||||
goto no_iop;
|
||||
}
|
||||
iop->unit = c2 == 2 ? ksh_numdig(dp[1]) : c == '<' ? 0 : 1;
|
||||
|
||||
if (c == '&') {
|
||||
if ((c2 = getsc()) != '>') {
|
||||
|
|
23
main.c
23
main.c
|
@ -34,7 +34,7 @@
|
|||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.313 2016/07/25 20:36:27 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.314 2016/07/25 21:05:22 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
|
@ -1471,25 +1471,20 @@ closepipe(int *pv)
|
|||
int
|
||||
check_fd(const char *name, int mode, const char **emsgp)
|
||||
{
|
||||
int fd = 0, fl;
|
||||
int fd, fl;
|
||||
|
||||
if (name[0] == 'p' && !name[1])
|
||||
if (!name[0] || name[1])
|
||||
goto illegal_fd_name;
|
||||
if (name[0] == 'p')
|
||||
return (coproc_getfd(mode, emsgp));
|
||||
while (ksh_isdigit(*name)) {
|
||||
fd = fd * 10 + ksh_numdig(*name);
|
||||
if (fd >= FDBASE) {
|
||||
if (emsgp)
|
||||
*emsgp = "file descriptor too large";
|
||||
return (-1);
|
||||
}
|
||||
++name;
|
||||
}
|
||||
if (*name) {
|
||||
if (!ksh_isdigit(name[0])) {
|
||||
illegal_fd_name:
|
||||
if (emsgp)
|
||||
*emsgp = "illegal file descriptor name";
|
||||
return (-1);
|
||||
}
|
||||
if ((fl = fcntl(fd, F_GETFL, 0)) < 0) {
|
||||
|
||||
if ((fl = fcntl((fd = ksh_numdig(name[0])), F_GETFL, 0)) < 0) {
|
||||
if (emsgp)
|
||||
*emsgp = "bad file descriptor";
|
||||
return (-1);
|
||||
|
|
8
mksh.1
8
mksh.1
|
@ -1,4 +1,4 @@
|
|||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.403 2016/07/25 20:41:23 tg Exp $
|
||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.404 2016/07/25 21:05:23 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,
|
||||
|
@ -2463,12 +2463,6 @@ indicating the file descriptor associated with the output of the current
|
|||
co-process; or the character
|
||||
.Ql \- ,
|
||||
indicating standard input is to be closed.
|
||||
.Pp
|
||||
Note that the current version of
|
||||
.Nm
|
||||
supports some two-digit fd numbers in some environments;
|
||||
this feature is deprecated and will be removed from a subsequent release
|
||||
in favour of a ksh93-/perl-style "named file descriptors" feature.
|
||||
.It \*(Gt& Ns Ar fd
|
||||
Same as
|
||||
.Ic \*(Lt& ,
|
||||
|
|
18
sh.h
18
sh.h
|
@ -175,9 +175,9 @@
|
|||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.778 2016/07/25 20:43:53 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.779 2016/07/25 21:05:24 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R52 2016/07/24"
|
||||
#define MKSH_VERSION "R53 2016/07/25"
|
||||
|
||||
/* arithmetic types: C implementation */
|
||||
#if !HAVE_CAN_INTTYPES
|
||||
|
@ -578,7 +578,7 @@ char *ucstrstr(char *, const char *);
|
|||
#define mkssert(e) do { } while (/* CONSTCOND */ 0)
|
||||
#endif
|
||||
|
||||
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 523)
|
||||
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 529)
|
||||
#error Must run Build.sh to compile this.
|
||||
extern void thiswillneverbedefinedIhope(void);
|
||||
int
|
||||
|
@ -634,17 +634,11 @@ im_sorry_dave(void)
|
|||
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||
#define MKSH_NO_CMDLINE_EDITING /* defined */
|
||||
#endif
|
||||
#ifndef MKSH_CONSERVATIVE_FDS
|
||||
#define MKSH_CONSERVATIVE_FDS /* defined */
|
||||
#endif
|
||||
#undef MKSH_S_NOVI
|
||||
#define MKSH_S_NOVI 1
|
||||
#endif
|
||||
|
||||
#ifdef MKSH_SMALL
|
||||
#ifndef MKSH_CONSERVATIVE_FDS
|
||||
#define MKSH_CONSERVATIVE_FDS /* defined */
|
||||
#endif
|
||||
#ifndef MKSH_NOPWNAM
|
||||
#define MKSH_NOPWNAM /* defined */
|
||||
#endif
|
||||
|
@ -661,14 +655,8 @@ im_sorry_dave(void)
|
|||
#define MKSH_UNEMPLOYED 1
|
||||
#endif
|
||||
|
||||
/* these shall be smaller than 100 */
|
||||
#ifdef MKSH_CONSERVATIVE_FDS
|
||||
#define NUFILE 32 /* Number of user-accessible files */
|
||||
#define FDBASE 10 /* First file usable by Shell */
|
||||
#else
|
||||
#define NUFILE 56 /* Number of user-accessible files */
|
||||
#define FDBASE 24 /* First file usable by Shell */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* simple grouping allocator
|
||||
|
|
11
syn.c
11
syn.c
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.112 2016/07/25 00:04:48 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.113 2016/07/25 21:05:25 tg Exp $");
|
||||
|
||||
struct nesting_state {
|
||||
int start_token; /* token than began nesting (eg, FOR) */
|
||||
|
@ -217,16 +217,7 @@ synio(int cf)
|
|||
char *cp;
|
||||
|
||||
nextiop = alloc(sizeof(*iop), ATEMP);
|
||||
#ifdef MKSH_CONSERVATIVE_FDS
|
||||
nextiop->ioname = cp = alloc(3, ATEMP);
|
||||
#else
|
||||
nextiop->ioname = cp = alloc(5, ATEMP);
|
||||
|
||||
if (iop->unit > 9) {
|
||||
*cp++ = CHAR;
|
||||
*cp++ = digits_lc[iop->unit / 10];
|
||||
}
|
||||
#endif
|
||||
*cp++ = CHAR;
|
||||
*cp++ = digits_lc[iop->unit % 10];
|
||||
*cp = EOS;
|
||||
|
|
Loading…
Reference in New Issue