fix x+=<<

This commit is contained in:
tg 2014-10-12 19:55:01 +00:00
parent 1971bb2ad4
commit 4afe543fa0
3 changed files with 29 additions and 8 deletions

24
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.662 2014/10/10 22:10:19 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.663 2014/10/12 19:54:58 tg Exp $
# OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -27,7 +27,7 @@
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout:
@(#)MIRBSD KSH R50 2014/10/07
@(#)MIRBSD KSH R50 2014/10/12
description:
Check version of shell.
stdin:
@ -36,7 +36,7 @@ name: KSH_VERSION
category: shell:legacy-no
---
expected-stdout:
@(#)LEGACY KSH R50 2014/10/07
@(#)LEGACY KSH R50 2014/10/12
description:
Check version of legacy shell.
stdin:
@ -2389,6 +2389,14 @@ stdin:
vf=<<<$'=f $x \x40='
# now check
print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
# check append
v=<<-EOF
vapp1
EOF
v+=<<-EOF
vapp2
EOF
print -r -- "| ${v//$'\n'/^} |"
expected-stdout:
function foo {
vc=<<-EOF
@ -2404,6 +2412,7 @@ expected-stdout:
} ve={=e $x \x40=
} vf={=f $x @=
} |
| vapp1^vapp2^ |
---
name: heredoc-11
description:
@ -2433,6 +2442,14 @@ stdin:
eval "$fnd"
foo
print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
# check append
v=<<-
vapp1
<<
v+=<<-''
vapp2
print -r -- "| ${v//$'\n'/^} |"
expected-stdout:
function foo {
vc=<<-
@ -2450,6 +2467,7 @@ expected-stdout:
} vc={=c u \x40=
} vd={=d $x \x40=
} |
| vapp1^vapp2^ |
---
name: heredoc-comsub-1
description:

9
exec.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.133 2014/10/03 17:32:11 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.134 2014/10/12 19:55:00 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@ -94,11 +94,14 @@ execute(struct op * volatile t,
/* the variable assignment begins with a valid varname */
(ccp = skip_wdvarname(t->vars[0], true)) != t->vars[0] &&
/* and has no right-hand side (i.e. "varname=") */
ccp[0] == CHAR && ccp[1] == '=' && ccp[2] == EOS &&
ccp[0] == CHAR && ((ccp[1] == '=' && ccp[2] == EOS) ||
/* or "varname+=" */ (ccp[1] == '+' && ccp[2] == CHAR &&
ccp[3] == '=' && ccp[4] == EOS)) &&
/* plus we can have a here document content */
herein(t->ioact[0], &cp) == 0 && cp && *cp) {
char *sp = cp, *dp;
size_t n = ccp - t->vars[0] + 2, z;
size_t n = ccp - t->vars[0] + (ccp[1] == '+' ? 4 : 2);
size_t z;
/* drop redirection (will be garbage collected) */
t->ioact = NULL;

4
sh.h
View File

@ -169,9 +169,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.697 2014/10/07 15:22:17 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.698 2014/10/12 19:55:01 tg Exp $");
#endif
#define MKSH_VERSION "R50 2014/10/07"
#define MKSH_VERSION "R50 2014/10/12"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES