first LEGACY changes: keep filedescriptors always open; revert to historic ‘set -- $(getopt …)’ behaviour
This commit is contained in:
48
check.t
48
check.t
@@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.539 2012/06/25 16:05:08 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.540 2012/06/25 16:17:51 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@@ -79,6 +79,19 @@ 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); echo 1 = $? .
|
||||||
|
(set -o vi); echo 2 = $? .
|
||||||
|
expected-stdout:
|
||||||
|
1 = 1 .
|
||||||
|
2 = 1 .
|
||||||
|
expected-stderr-pattern:
|
||||||
|
/set: emacs: bad option\n.*set: vi: bad option/
|
||||||
|
---
|
||||||
name: selftest-direct-builtin-call
|
name: selftest-direct-builtin-call
|
||||||
description:
|
description:
|
||||||
Check that direct builtin calls work
|
Check that direct builtin calls work
|
||||||
@@ -4088,6 +4101,7 @@ description:
|
|||||||
but not 0 according to the getopt(1) manual page, ksh88, and
|
but not 0 according to the getopt(1) manual page, ksh88, and
|
||||||
Bourne sh (such as /bin/sh on Solaris).
|
Bourne sh (such as /bin/sh on Solaris).
|
||||||
In mksh R39b, we honour POSIX except when -o sh is set.
|
In mksh R39b, we honour POSIX except when -o sh is set.
|
||||||
|
category: shell:legacy-no
|
||||||
stdin:
|
stdin:
|
||||||
showf() {
|
showf() {
|
||||||
[[ -o posix ]]; FPOSIX=$((1-$?))
|
[[ -o posix ]]; FPOSIX=$((1-$?))
|
||||||
@@ -4111,6 +4125,38 @@ expected-stdout:
|
|||||||
FPOSIX=0 FSH=1 rv=1
|
FPOSIX=0 FSH=1 rv=1
|
||||||
FPOSIX=1 FSH=0 rv=0
|
FPOSIX=1 FSH=0 rv=0
|
||||||
---
|
---
|
||||||
|
name: regression-10-legacy
|
||||||
|
description:
|
||||||
|
The following:
|
||||||
|
set -- `false`
|
||||||
|
echo $?
|
||||||
|
should print 0 according to POSIX (dash, bash, ksh93, posh)
|
||||||
|
but not 0 according to the getopt(1) manual page, ksh88, and
|
||||||
|
Bourne sh (such as /bin/sh on Solaris).
|
||||||
|
category: shell:legacy-yes
|
||||||
|
stdin:
|
||||||
|
showf() {
|
||||||
|
[[ -o posix ]]; FPOSIX=$((1-$?))
|
||||||
|
[[ -o sh ]]; FSH=$((1-$?))
|
||||||
|
echo -n "FPOSIX=$FPOSIX FSH=$FSH "
|
||||||
|
}
|
||||||
|
set +o posix +o sh
|
||||||
|
showf
|
||||||
|
set -- `false`
|
||||||
|
echo rv=$?
|
||||||
|
set -o sh
|
||||||
|
showf
|
||||||
|
set -- `false`
|
||||||
|
echo rv=$?
|
||||||
|
set -o posix
|
||||||
|
showf
|
||||||
|
set -- `false`
|
||||||
|
echo rv=$?
|
||||||
|
expected-stdout:
|
||||||
|
FPOSIX=0 FSH=0 rv=0
|
||||||
|
FPOSIX=0 FSH=1 rv=0
|
||||||
|
FPOSIX=1 FSH=0 rv=0
|
||||||
|
---
|
||||||
name: regression-11
|
name: regression-11
|
||||||
description:
|
description:
|
||||||
The following:
|
The following:
|
||||||
|
8
funcs.c
8
funcs.c
@@ -38,7 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.220 2012/06/24 20:00:51 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.221 2012/06/25 16:17:54 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@@ -2407,7 +2407,11 @@ c_set(const char **wp)
|
|||||||
* if there are no command substitutions).
|
* if there are no command substitutions).
|
||||||
* Switched ksh (!posix !sh) to POSIX in mksh R39b.
|
* Switched ksh (!posix !sh) to POSIX in mksh R39b.
|
||||||
*/
|
*/
|
||||||
|
#ifdef MKSH_LEGACY_MODE
|
||||||
|
return (subst_exstat);
|
||||||
|
#else
|
||||||
return (Flag(FSH) ? subst_exstat : 0);
|
return (Flag(FSH) ? subst_exstat : 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -2612,6 +2616,7 @@ 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]);
|
||||||
|
#ifdef 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
|
||||||
@@ -2619,6 +2624,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user