also do not, ever, use &> bashiop in lksh

This commit is contained in:
tg 2013-03-29 17:33:56 +00:00
parent 41ae60bb55
commit ea657bd4d9
3 changed files with 41 additions and 18 deletions

46
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.601 2013/03/24 15:01:46 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.602 2013/03/29 17:33:53 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 $
@ -29,7 +29,7 @@
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD # http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R44 2013/03/24 @(#)MIRBSD KSH R44 2013/03/29
description: description:
Check version of shell. Check version of shell.
stdin: stdin:
@ -38,7 +38,7 @@ name: KSH_VERSION
category: shell:legacy-no category: shell:legacy-no
--- ---
expected-stdout: expected-stdout:
@(#)LEGACY KSH R44 2013/03/24 @(#)LEGACY KSH R44 2013/03/29
description: description:
Check version of legacy shell. Check version of legacy shell.
stdin: stdin:
@ -8363,6 +8363,7 @@ 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 {
@ -8383,6 +8384,7 @@ 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 {
@ -8403,6 +8405,7 @@ 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 {
@ -8423,6 +8426,7 @@ 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
@ -8446,6 +8450,7 @@ 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
@ -8467,6 +8472,7 @@ 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
@ -8490,6 +8496,7 @@ 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 {
@ -8511,20 +8518,33 @@ expected-stdout:
ras ras
dwa dwa
--- ---
name: bashiop-5 name: bashiop-5-normal
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
(tested only on MirBSD as it uses /dev/fd) category: shell:legacy-no
category: os:mirbsd
stdin: stdin:
"$__progname" -c 'echo foo>/dev/null&>/dev/fd/2 echo bar1' :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
"$__progname" -o posix -c 'echo foo>/dev/null&>/dev/fd/2 echo bar2' :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
"$__progname" -o sh -c 'echo foo>/dev/null&>/dev/fd/2 echo bar3' :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
expected-stderr: expected-stdout:
foo echo bar1 1 = foo echo bar .
bar2 2 = bar .
bar3 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: mkshiop-1 name: mkshiop-1
description: description:

9
lex.c
View File

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.183 2013/03/24 15:01:48 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.184 2013/03/29 17:33:55 tg Exp $");
/* /*
* states while lexing word * states while lexing word
@ -898,8 +898,11 @@ yylex(int cf)
state = SBASE; state = SBASE;
dp = Xstring(ws, wp); dp = Xstring(ws, wp);
if (state == SBASE && (c == '<' || c == '>' || if (state == SBASE && (
(!Flag(FSH) && !Flag(FPOSIX) && c == '&'))) { #ifndef MKSH_LEGACY_MODE
(c == '&' && !Flag(FSH) && !Flag(FPOSIX)) ||
#endif
c == '<' || c == '>')) {
struct ioword *iop = alloc(sizeof(struct ioword), ATEMP); struct ioword *iop = alloc(sizeof(struct ioword), ATEMP);
if (Xlength(ws, wp) == 0) if (Xlength(ws, wp) == 0)

4
sh.h
View File

@ -164,9 +164,9 @@
#endif #endif
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.644 2013/03/24 15:01:50 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.645 2013/03/29 17:33:56 tg Exp $");
#endif #endif
#define MKSH_VERSION "R44 2013/03/24" #define MKSH_VERSION "R44 2013/03/29"
/* arithmetic types: C implementation */ /* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES #if !HAVE_CAN_INTTYPES