Fix two more POSIX conformance bugs and minor documentation/comment issues

This commit is contained in:
tg 2010-04-08 13:21:08 +00:00
parent 2557cfbbe5
commit ff9f89f22f
6 changed files with 70 additions and 16 deletions

49
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.370 2010/03/27 16:53:15 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.371 2010/04/08 13:21:03 tg 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: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R39 2010/03/27
@(#)MIRBSD KSH R39 2010/04/08
description:
Check version of shell.
stdin:
@ -1044,6 +1044,8 @@ stdin:
(echo -n '35 '; printf '<%s> ' ${v=a\ b} x ${v=c\ d}; echo .) 2>&- || echo failed in 35
(echo -n '36 '; printf '<%s> ' "${v=a\ b}" x "${v=c\ d}"; echo .) 2>&- || echo failed in 36
(echo -n '37 '; printf '<%s> ' ${v-a\ b} x ${v-c\ d}; echo .) 2>&- || echo failed in 37
(echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>&- || echo failed in 38
foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>&- || echo failed in 39
expected-stdout:
1 }z
2 ''z}
@ -1082,6 +1084,8 @@ expected-stdout:
35 <a> <b> <x> <a> <b> .
36 <a\ b> <x> <a\ b> .
37 <a b> <x> <c d> .
38 xay / x'a'y .
39 x' / x' .
---
name: expand-unglob-dblq
description:
@ -4390,6 +4394,47 @@ stdin:
expected-stdout:
123
---
name: xxx-multi-assignment-posix-cmd
description:
Check that the behaviour for multiple assignments with a
command name matches POSIX. See:
http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
stdin:
X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
expected-stdout:
1 b a .
2 a b .
---
name: xxx-multi-assignment-posix-nocmd
description:
Check that the behaviour for multiple assignments with no
command name matches POSIX (Debian #334182). See:
http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
stdin:
X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
expected-stdout:
1 b b .
---
name: xxx-multi-assignment-posix-subassign
description:
Check that the behaviour for multiple assignments matches POSIX:
- The assignment words shall be expanded in the current execution
environment.
- The assignments happen in the temporary execution environment.
stdin:
unset X Y Z
Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
echo /$X/
# Now for the special case:
unset X Y Z
X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
echo /$X/
expected-stdout:
++ +b+ +a+
/b/
++ +b+
/b/
---
name: xxx-exec-environment-1
description:
Check to see if exec sets it's environment correctly

4
eval.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.83 2010/02/25 20:18:15 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.84 2010/04/08 13:21:04 tg Exp $");
/*
* string expansion
@ -517,7 +517,7 @@ expand(const char *cp, /* input word */
/* ! DOBLANK,DOBRACE_,DOTILDE */
f = DOPAT | (f&DONTRUNCOMMAND) |
DOTEMP_;
quote = 0;
st->quote = quote = 0;
/* Prepend open pattern (so |
* in a trim will work as
* expected)

10
exec.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.73 2010/03/27 15:29:00 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.74 2010/04/08 13:21:05 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@ -412,6 +412,7 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
int keepasn_ok;
int fcflags = FC_BI|FC_FUNC|FC_PATH;
bool bourne_function_call = false;
struct block *l_expand, *l_assign;
/* snag the last argument for $_ XXX not the same as AT&T ksh,
* which only seems to set $_ after a newline (but not in
@ -491,6 +492,7 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
break;
tp = findcom(ap[0], fcflags & (FC_BI|FC_FUNC));
}
l_expand = e->loc;
if (keepasn_ok && (!ap[0] || (tp && (tp->flag & KEEPASN))))
type_flags = 0;
else {
@ -504,10 +506,16 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
} else
type_flags = LOCAL|LOCAL_COPY|EXPORT;
}
l_assign = e->loc;
if (Flag(FEXPORT))
type_flags |= EXPORT;
for (i = 0; t->vars[i]; i++) {
/* do NOT lookup in the new var/fn block just created */
e->loc = l_expand;
cp = evalstr(t->vars[i], DOASNTILDE);
e->loc = l_assign;
/* but assign in there as usual */
if (Flag(FXTRACE)) {
if (i == 0)
shf_fprintf(shl_out, "%s",

7
lex.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.112 2010/03/31 12:20:04 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.113 2010/04/08 13:21:06 tg Exp $");
/*
* states while lexing word
@ -725,9 +725,8 @@ yylex(int cf)
break;
case STBRACE:
/* Same as SBRACE, except (,|,) treated specially */
/*{*/
if (c == '}') {
/* Same as SBASE, except (,|,) treated specially */
if (c == /*{*/ '}') {
POP_STATE();
*wp++ = CSUBST;
*wp++ = /*{*/ '}';

12
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.222 2010/03/27 20:36:26 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.223 2010/04/08 13:21:06 tg Exp $
.\" $OpenBSD: ksh.1,v 1.131 2010/02/26 03:32:39 william Exp $
.\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
@ -71,7 +71,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 27 2010 $
.Dd $Mdocdate: April 8 2010 $
.\"
.\" Check which macro package we use
.\"
@ -1419,9 +1419,11 @@ error message is also printed.
Note that, for all of the above,
.Ar word
is actually considered quoted, and special parsing rules apply.
The parsing rules also differ on whether the expression is
double-quoted with respect to the single quote
.Pq Dq \*(aq .
The parsing rules also differ on whether the expression is double-quoted:
.Ar word
then uses double-quoting rules, except for the double quote itself
.Pq Sq \&"
and the closing brace, which, if backslash escaped, gets quote removal applied.
.Pp
In the above modifiers, the
.Ql \&:

4
sh.h
View File

@ -150,9 +150,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.386 2010/03/27 16:53:17 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.387 2010/04/08 13:21:08 tg Exp $");
#endif
#define MKSH_VERSION "R39 2010/03/27"
#define MKSH_VERSION "R39 2010/04/08"
#ifndef MKSH_INCLUDES_ONLY