Merge remote-tracking branch 'mksh/master'

This commit is contained in:
KO Myung-Hun 2015-09-12 12:50:57 +09:00
commit bd9de444e3
24 changed files with 210 additions and 215 deletions

View File

@ -1,9 +1,9 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.689 2015/07/10 17:16:23 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.690 2015/09/05 19:18:59 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015
# Thorsten “mirabilos” Glaser <tg@mirbsd.org>
# mirabilos <tg@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
@ -2416,7 +2416,7 @@ cat >test.sh <<-EOF
args[\${#args[*]}]=\$TMPDIR
fi
print Testing mksh for conformance:
fgrep -e MirOS: -e MIRBSD "\$sflag"
fgrep -e Mir''OS: -e MIRBSD "\$sflag"
print "This shell is actually:\\n\\t\$KSH_VERSION"
print 'test.sh built for mksh $dstversion'
cstr='\$os = defined \$^O ? \$^O : "unknown";'

View File

@ -1,8 +1,8 @@
# $MirOS: src/bin/mksh/Makefile,v 1.142 2015/07/09 20:52:36 tg Exp $
# $MirOS: src/bin/mksh/Makefile,v 1.143 2015/09/05 19:19:00 tg Exp $
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015
# Thorsten “mirabilos” Glaser <tg@mirbsd.org>
# mirabilos <tg@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
@ -154,7 +154,7 @@ cats: ${MANALL} ${MANALL:S/.cat/.ps/}
.endif
.for _m _n in mksh 1
x=$$(ident ${SRCDIR:Q}/${_m}.${_n} | \
awk '/MirOS:/ { print $$4$$5; }' | \
awk '/Mir''OS:/ { print $$4$$5; }' | \
tr -dc 0-9); (( $${#x} == 14 )) || exit 1; exec \
${MKSH} ${BSDSRCDIR:Q}/contrib/hosted/tg/ps2pdfmir -c \
-o ${_m}.${_n}.pdf '[' /Author '(The MirOS Project)' \

View File

@ -1,9 +1,9 @@
# $MirOS: src/bin/mksh/check.pl,v 1.40 2015/07/10 19:36:31 tg Exp $
# $MirOS: src/bin/mksh/check.pl,v 1.41 2015/09/05 19:19:01 tg Exp $
# $OpenBSD: th,v 1.1 2013/12/02 20:39:44 millert Exp $
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011,
# 2012, 2013, 2014, 2015
# Thorsten Glaser <tg@mirbsd.org>
# mirabilos <tg@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission

89
check.t
View File

@ -1,9 +1,9 @@
# $MirOS: src/bin/mksh/check.t,v 1.705 2015/08/13 22:06:19 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.707 2015/09/06 19:46:56 tg Exp $
# -*- mode: sh -*-
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015
# Thorsten Glaser <tg@mirbsd.org>
# mirabilos <tg@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
@ -30,7 +30,7 @@
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout:
@(#)MIRBSD KSH R51 2015/08/13
@(#)MIRBSD KSH R51 2015/09/06
description:
Check version of shell.
stdin:
@ -39,7 +39,7 @@ name: KSH_VERSION
category: shell:legacy-no
---
expected-stdout:
@(#)LEGACY KSH R51 2015/08/13
@(#)LEGACY KSH R51 2015/09/06
description:
Check version of legacy shell.
stdin:
@ -2325,6 +2325,8 @@ stdin:
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"A $(echo "foo bar") B"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$b\$b$bar
expected-stdout:
sbb
sbb
@ -2334,6 +2336,9 @@ expected-stdout:
$one
-sbb
sbb one
A sbb one B
$o$oone
onm
---
name: heredoc-9b
description:
@ -2423,7 +2428,7 @@ stdin:
print -r -- "| ${v//$'\n'/^} |"
expected-stdout:
function foo {
vc=<<-EOF
vc=<<-EOF
=c $x \x40=
EOF
@ -2476,11 +2481,11 @@ stdin:
print -r -- "| ${v//$'\n'/^} |"
expected-stdout:
function foo {
vc=<<-
vc=<<-
=c $x \x40=
<<
vd=<<-""
vd=<<-""
=d $x \x40=
@ -2538,6 +2543,46 @@ expected-stdout:
3 baz a b baz
3 bla "a b" bla
---
name: heredoc-14
description:
Check that using multiple here documents works
stdin:
foo() {
echo "got $(cat) on stdin"
echo "got $(cat <&4) on fd#4"
echo "got $(cat <&5) on fd#5"
}
bar() {
foo 4<<-a <<-b 5<<-c
four
a
zero
b
five
c
}
x=$(typeset -f bar)
eval "$x"
y=$(typeset -f bar)
[[ $x = "$y" ]]; echo $?
typeset -f bar
bar
expected-stdout:
0
bar() {
foo 4<<-a <<-b 5<<-c
four
a
zero
b
five
c
}
got zero on stdin
got four on fd#4
got five on fd#5
---
name: heredoc-comsub-1
description:
Tests for here documents in COMSUB, taken from Austin ML
@ -10566,7 +10611,7 @@ expected-stdout:
EOFN
}
inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
cat >|bar <<"EOFN"
cat >|bar <<"EOFN"
foo
EOFN
@ -10577,7 +10622,7 @@ expected-stdout:
EOFN
); }
function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
x=$(cat >|bar <<"EOFN"
x=$(cat >|bar <<"EOFN"
foo
EOFN
)
@ -10588,7 +10633,7 @@ expected-stdout:
EOFN
)|tr u x); }
function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
x=$(( cat >|bar <<"EOFN"
x=$(( cat >|bar <<"EOFN"
foo
EOFN
) | tr u x )
@ -10599,7 +10644,7 @@ expected-stdout:
EOFI
}
inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
cat >bar <<-EOFI
cat >bar <<-EOFI
foo
EOFI
@ -10610,7 +10655,7 @@ expected-stdout:
EOFI
); }
function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
x=$(cat >bar <<-EOFI
x=$(cat >bar <<-EOFI
foo
EOFI
)
@ -10621,7 +10666,7 @@ expected-stdout:
EOFI
)|tr u x); }
function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
x=$(( cat >bar <<-EOFI
x=$(( cat >bar <<-EOFI
foo
EOFI
) | tr u x )
@ -10712,7 +10757,7 @@ expected-stdout:
EOFN); echo $x
}
inline_heredoc_closed() {
x=$(cat <<EOFN
x=$(cat <<EOFN
note there must be no space between EOFN and )
EOFN
)
@ -10724,7 +10769,7 @@ expected-stdout:
EOFN); echo $x
); }
function comsub_heredoc_closed {
x=$(x=$(cat <<EOFN
x=$(x=$(cat <<EOFN
note there must be no space between EOFN and )
EOFN
) ; echo $x )
@ -10735,7 +10780,7 @@ expected-stdout:
EOFN); echo $x
)|tr u x); }
function reread_heredoc_closed {
x=$(( x=$(cat <<EOFN
x=$(( x=$(cat <<EOFN
note there must be no space between EOFN and )
EOFN
) ; echo $x ) | tr u x )
@ -10746,7 +10791,7 @@ expected-stdout:
EOFN ); echo $x
}
inline_heredoc_space() {
x=$(cat <<EOFN\
x=$(cat <<EOFN\
note the space between EOFN and ) is actually part of the here document marker
EOFN
)
@ -10758,7 +10803,7 @@ expected-stdout:
EOFN ); echo $x
); }
function comsub_heredoc_space {
x=$(x=$(cat <<EOFN\
x=$(x=$(cat <<EOFN\
note the space between EOFN and ) is actually part of the here document marker
EOFN
) ; echo $x )
@ -10769,7 +10814,7 @@ expected-stdout:
EOFN ); echo $x
)|tr u x); }
function reread_heredoc_space {
x=$(( x=$(cat <<EOFN\
x=$(( x=$(cat <<EOFN\
note the space between EOFN and ) is actually part of the here document marker
EOFN
) ; echo $x ) | tr u x )
@ -10792,7 +10837,7 @@ expected-stdout:
}
inline_patch_motd() {
x=$(sysctl -n kern.version | sed 1q )
[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
1,/^\$/d
0a
$x
@ -10824,7 +10869,7 @@ expected-stdout:
fi
); }
function comsub_patch_motd {
x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
1,/^\$/d
0a
$x
@ -10851,7 +10896,7 @@ expected-stdout:
fi
)|tr u x); }
function reread_patch_motd {
x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
1,/^\$/d
0a
$x

20
edit.c
View File

@ -1,12 +1,12 @@
/* $OpenBSD: edit.c,v 1.40 2015/03/12 10:20:30 sthen Exp $ */
/* $OpenBSD: edit.c,v 1.41 2015/09/01 13:12:31 tedu Exp $ */
/* $OpenBSD: edit.h,v 1.9 2011/05/30 17:14:35 martynas Exp $ */
/* $OpenBSD: emacs.c,v 1.50 2015/03/25 12:10:52 jca Exp $ */
/* $OpenBSD: vi.c,v 1.28 2013/12/18 16:45:46 deraadt Exp $ */
/* $OpenBSD: emacs.c,v 1.51 2015/09/01 13:12:31 tedu Exp $ */
/* $OpenBSD: vi.c,v 1.29 2015/09/01 13:12:31 tedu Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014
* Thorsten Glaser <tg@mirbsd.org>
* 2011, 2012, 2013, 2014, 2015
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -28,7 +28,7 @@
#ifndef MKSH_NO_CMDLINE_EDITING
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.290 2015/07/10 19:36:34 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.291 2015/09/05 19:19:01 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@ -2266,12 +2266,8 @@ x_kill(int c MKSH_A_UNUSED)
static void
x_push(int nchars)
{
char *cp;
strndupx(cp, xcp, nchars, AEDIT);
if (killstack[killsp])
afree(killstack[killsp], AEDIT);
killstack[killsp] = cp;
afree(killstack[killsp], AEDIT);
strndupx(killstack[killsp], xcp, nchars, AEDIT);
killsp = (killsp + 1) % KILLSIZE;
}

6
eval.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.170 2015/07/06 17:45:33 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.172 2015/09/06 19:46:59 tg Exp $");
/*
* string expansion
@ -919,6 +919,8 @@ expand(
(word == IFS_IWS || word == IFS_NWS) &&
!ctype(c, C_IFSWS))) {
emit_word:
if (f & DOHERESTR)
*dp++ = '\n';
*dp++ = '\0';
cp = Xclose(ds, dp);
if (fdo & DOBRACE)

20
exec.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.160 2015/07/10 19:36:35 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.163 2015/09/06 19:46:59 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"
@ -1524,7 +1524,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
char *sp;
eno = errno;
warningf(true, "%s %s %s",
warningf(true, "%s %s: %s",
"can't finish (dup) redirection",
(sp = snptreef(NULL, 32, "%R", &iotmp)),
cstrerror(eno));
@ -1560,9 +1560,9 @@ iosetup(struct ioword *iop, struct tbl *tp)
* unquoted, the string is expanded first.
*/
static int
hereinval(const char *content, int sub, char **resbuf, struct shf *shf)
hereinval(struct ioword *iop, int sub, char **resbuf, struct shf *shf)
{
const char * volatile ccp = content;
const char * volatile ccp = iop->heredoc;
struct source *s, *osource;
osource = source;
@ -1573,7 +1573,9 @@ hereinval(const char *content, int sub, char **resbuf, struct shf *shf)
/* special to iosetup(): don't print error */
return (-2);
}
if (sub) {
if (iop->ioflag & IOHERESTR) {
ccp = evalstr(iop->delim, DOHERESTR | DOSCALAR | DOHEREDOC);
} else if (sub) {
/* do substitutions on the content of heredoc */
s = pushs(SSTRING, ATEMP);
s->start = s->str = ccp;
@ -1602,7 +1604,7 @@ herein(struct ioword *iop, char **resbuf)
int i;
/* ksh -c 'cat <<EOF' can cause this... */
if (iop->heredoc == NULL) {
if (iop->heredoc == NULL && !(iop->ioflag & IOHERESTR)) {
warningf(true, "%s missing", "here document");
/* special to iosetup(): don't print error */
return (-2);
@ -1613,7 +1615,7 @@ herein(struct ioword *iop, char **resbuf)
/* skip all the fd setup if we just want the value */
if (resbuf != NULL)
return (hereinval(iop->heredoc, i, resbuf, NULL));
return (hereinval(iop, i, resbuf, NULL));
/*
* Create temp file to hold content (done before newenv
@ -1630,7 +1632,7 @@ herein(struct ioword *iop, char **resbuf)
return (-2);
}
if (hereinval(iop->heredoc, i, NULL, shf) == -2) {
if (hereinval(iop, i, NULL, shf) == -2) {
close(fd);
/* special to iosetup(): don't print error */
return (-2);

4
expr.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.77 2014/12/15 23:26:36 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.78 2015/09/05 19:19:03 tg Exp $");
/* the order of these enums is constrained by the order of opinfo[] */
enum token {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: c_ksh.c,v 1.34 2013/12/17 16:37:05 deraadt Exp $ */
/* $OpenBSD: c_ksh.c,v 1.35 2015/09/01 13:12:31 tedu Exp $ */
/* $OpenBSD: c_sh.c,v 1.46 2015/07/20 20:46:24 guenther Exp $ */
/* $OpenBSD: c_test.c,v 1.18 2009/03/01 20:11:06 otto Exp $ */
/* $OpenBSD: c_ulimit.c,v 1.19 2013/11/28 10:33:37 sobrado Exp $ */
@ -6,7 +6,7 @@
/*-
* Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
* 2010, 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.282 2015/08/13 21:38:17 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.283 2015/09/05 19:19:04 tg Exp $");
#if HAVE_KILLPG
/*

View File

@ -1,10 +1,10 @@
/* $OpenBSD: history.c,v 1.40 2014/11/20 15:22:39 tedu Exp $ */
/* $OpenBSD: history.c,v 1.41 2015/09/01 13:12:31 tedu Exp $ */
/* $OpenBSD: trap.c,v 1.23 2010/05/19 17:36:08 jasper Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -27,7 +27,7 @@
#include <sys/file.h>
#endif
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.149 2015/07/09 20:52:40 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.150 2015/09/05 19:19:05 tg Exp $");
Trap sigtraps[ksh_NSIG + 1];
static struct sigaction Sigact_ign;
@ -898,8 +898,7 @@ histload(Source *s, unsigned char *base, size_t bytes)
if (lno >= s->line - (histptr - history) && lno <= s->line) {
hp = &histptr[lno - s->line];
if (*hp)
afree(*hp, APERM);
afree(*hp, APERM);
strdupx(*hp, (char *)(base + 4), APERM);
}
} else {
@ -1376,8 +1375,7 @@ settrap(Trap *p, const char *s)
{
sig_t f;
if (p->trap)
afree(p->trap, APERM);
afree(p->trap, APERM);
/* handles s == NULL */
strdupx(p->trap, s, APERM);
p->flags |= TF_CHANGED;

6
jobs.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011,
* 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.113 2015/08/13 21:38:19 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.115 2015/09/05 19:19:05 tg Exp $");
#if HAVE_KILLPG
#define mksh_killpg killpg
@ -892,7 +892,7 @@ j_resume(const char *cp, int bg)
(long)kshpgrp, "failed", cstrerror(errno));
}
sigprocmask(SIG_SETMASK, &omask, NULL);
bi_errorf("%s %s %s", "can't continue job",
bi_errorf("%s %s: %s", "can't continue job",
cp, cstrerror(eno));
return (1);
}

View File

@ -1,6 +1,6 @@
/*-
* Copyright (c) 2009, 2010, 2011, 2013, 2014
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -20,7 +20,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.21 2014/11/25 20:00:39 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.22 2015/09/05 19:19:06 tg Exp $");
/* build with CPPFLAGS+= -DUSE_REALLOC_MALLOC=0 on ancient systems */
#if defined(USE_REALLOC_MALLOC) && (USE_REALLOC_MALLOC == 0)

94
lex.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.205 2015/08/13 21:04:12 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.209 2015/09/06 19:47:00 tg Exp $");
/*
* states while lexing word
@ -38,8 +38,8 @@ __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.205 2015/08/13 21:04:12 tg Exp $");
#define SQBRACE 7 /* inside "${}" */
#define SBQUOTE 8 /* inside `` */
#define SASPAREN 9 /* inside $(( )) */
#define SHEREDELIM 10 /* parsing <<,<<-,<<< delimiter */
#define SHEREDQUOTE 11 /* parsing " in <<,<<-,<<< delimiter */
#define SHEREDELIM 10 /* parsing << or <<- delimiter */
#define SHEREDQUOTE 11 /* parsing " in << or <<- delimiter */
#define SPATTERN 12 /* parsing *(...|...) pattern (*+?@!) */
#define SADELIM 13 /* like SBASE, looking for delimiter */
#define STBRACEKORN 14 /* parsing ${...[#%]...} !FSH */
@ -61,7 +61,7 @@ typedef struct lex_state {
/* point to the next state block */
struct lex_state *base;
/* marks start of state output in output string */
int start;
size_t start;
/* SBQUOTE: true if in double quotes: "`...`" */
/* SEQUOTE: got NUL, ignore rest of string */
bool abool;
@ -98,7 +98,7 @@ static int s_get(void);
static void s_put(int);
static char *get_brace_var(XString *, char *);
static bool arraysub(char **);
static void gethere(bool);
static void gethere(void);
static Lex_state *push_state_i(State_info *, Lex_state *);
static Lex_state *pop_state_i(State_info *, Lex_state *);
@ -240,20 +240,6 @@ yylex(int cf)
/* Initial state: one of SWORD SLETPAREN SHEREDELIM SBASE */
statep->type = state;
/* check for here string */
if (state == SHEREDELIM) {
c = getsc();
if (c == '<') {
state = SHEREDELIM;
while ((c = getsc()) == ' ' || c == '\t')
;
ungetsc(c);
c = '<';
goto accept_nonword;
}
ungetsc(c);
}
/* collect non-special or quoted characters to form word */
while (!((c = getsc()) == 0 ||
((state == SBASE || state == SHEREDELIM) && ctype(c, C_LEX1)))) {
@ -262,7 +248,6 @@ yylex(int cf)
c == /*{*/ '}')
/* possibly end ${ :;} */
break;
accept_nonword:
Xcheck(ws, wp);
switch (state) {
case SADELIM:
@ -806,7 +791,7 @@ yylex(int cf)
++statep->nparen;
goto Sbase2;
/* <<, <<-, <<< delimiter */
/* << or <<- delimiter */
case SHEREDELIM:
/*
* here delimiters need a special case since
@ -844,7 +829,7 @@ yylex(int cf)
}
break;
/* " in <<, <<-, <<< delimiter */
/* " in << or <<- delimiter */
case SHEREDQUOTE:
if (c != '"')
goto Subst;
@ -941,14 +926,12 @@ yylex(int cf)
iop->ioflag |= c == c2 ?
(c == '>' ? IOCAT : IOHERE) : IORDWR;
if (iop->ioflag == IOHERE) {
if ((c2 = getsc()) == '-') {
if ((c2 = getsc()) == '-')
iop->ioflag |= IOSKIP;
c2 = getsc();
} else if (c2 == '<')
else if (c2 == '<')
iop->ioflag |= IOHERESTR;
ungetsc(c2);
if (c2 == '\n')
iop->ioflag |= IONDELIM;
else
ungetsc(c2);
}
} else if (c2 == '&')
iop->ioflag |= IODUP | (c == '<' ? IORDUP : 0);
@ -998,12 +981,14 @@ yylex(int cf)
}
#endif
} else if (c == '\n') {
gethere(false);
if (cf & CONTIN)
goto Again;
} else if (c == '\0')
/* need here strings at EOF */
gethere(true);
if (cf & HEREDELIM)
ungetsc(c);
else {
gethere();
if (cf & CONTIN)
goto Again;
}
}
return (c);
}
@ -1026,23 +1011,8 @@ yylex(int cf)
/* copy word to unprefixed string ident */
sp = yylval.cp;
dp = ident;
if ((cf & HEREDELIM) && (sp[1] == '<')) {
herestringloop:
switch ((c = *sp++)) {
case CHAR:
++sp;
/* FALLTHROUGH */
case OQUOTE:
case CQUOTE:
goto herestringloop;
default:
break;
}
/* dummy value */
*dp++ = 'x';
} else
while ((dp - ident) < IDENT && (c = *sp++) == CHAR)
*dp++ = *sp++;
while ((dp - ident) < IDENT && (c = *sp++) == CHAR)
*dp++ = *sp++;
if (c != EOS)
/* word is not unquoted */
dp = ident;
@ -1118,15 +1088,12 @@ yylex(int cf)
}
static void
gethere(bool iseof)
gethere(void)
{
struct ioword **p;
for (p = heres; p < herep; p++)
if (iseof && !((*p)->ioflag & IOHERESTR))
/* only here strings at EOF */
return;
else
if (!((*p)->ioflag & IOHERESTR))
readhere(*p);
herep = heres;
}
@ -1142,18 +1109,9 @@ readhere(struct ioword *iop)
const char *eof, *eofp;
XString xs;
char *xp;
int xpos;
size_t xpos;
if (iop->ioflag & IOHERESTR) {
/* process the here string */
iop->heredoc = xp = evalstr(iop->delim, DOBLANK);
xpos = strlen(xp) - 1;
memmove(xp, xp + 1, xpos);
xp[xpos] = '\n';
return;
}
eof = iop->ioflag & IONDELIM ? "<<" : evalstr(iop->delim, 0);
eof = evalstr(iop->delim, 0);
if (!(iop->ioflag & IOEVAL))
ignore_backslash_newline++;

6
lksh.1
View File

@ -1,7 +1,7 @@
.\" $MirOS: src/bin/mksh/lksh.1,v 1.10 2015/04/12 22:32:12 tg Exp $
.\" $MirOS: src/bin/mksh/lksh.1,v 1.11 2015/09/05 19:19:06 tg Exp $
.\"-
.\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015
.\" Thorsten “mirabilos” Glaser <tg@mirbsd.org>
.\" mirabilos <tg@mirbsd.org>
.\"
.\" Provided that these terms and disclaimer and all copyright notices
.\" are retained or reproduced in an accompanying document, permission
@ -72,7 +72,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
.Dd $Mdocdate: April 12 2015 $
.Dd $Mdocdate: September 5 2015 $
.\"
.\" Check which macro package we use, and do other -mdoc setup.
.\"

10
main.c
View File

@ -1,12 +1,12 @@
/* $OpenBSD: main.c,v 1.55 2015/02/09 09:09:30 jsg Exp $ */
/* $OpenBSD: main.c,v 1.56 2015/09/01 17:46:31 tedu Exp $ */
/* $OpenBSD: tty.c,v 1.10 2014/08/10 02:44:26 guenther Exp $ */
/* $OpenBSD: io.c,v 1.25 2014/08/11 20:28:47 guenther Exp $ */
/* $OpenBSD: table.c,v 1.15 2012/02/19 07:52:30 otto Exp $ */
/* $OpenBSD: table.c,v 1.16 2015/09/01 13:12:31 tedu Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.301 2015/08/13 22:06:22 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.302 2015/09/05 19:19:06 tg Exp $");
extern char **environ;
@ -202,7 +202,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
/* do things like getpgrp() et al. */
chvt_reinit();
/* make sure argv[] is sane */
/* make sure argv[] is sane, for weird OSes */
if (!*argv) {
argv = empty_argv;
argc = 1;

View File

@ -1,6 +1,6 @@
/*-
* Copyright © 2011, 2014, 2015
* Thorsten mirabilos Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -44,7 +44,7 @@
#include <sys/types.h>
__RCSID("$MirOS: src/bin/mksh/mirhash.h,v 1.4 2015/05/30 22:14:06 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/mirhash.h,v 1.5 2015/09/05 19:19:07 tg Exp $");
/*-
* BAFH itself is defined by the following primitives:

12
misc.c
View File

@ -1,10 +1,10 @@
/* $OpenBSD: misc.c,v 1.40 2015/03/18 15:12:36 tedu Exp $ */
/* $OpenBSD: path.c,v 1.12 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: path.c,v 1.13 2015/09/05 09:47:08 jsg Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -30,7 +30,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.238 2015/07/10 19:36:36 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.239 2015/09/05 19:19:07 tg Exp $");
#define KSH_CHVT_FLAG
#ifdef MKSH_SMALL
@ -1579,16 +1579,14 @@ do_realpath(const char *upath)
}
/* return target path */
if (ldest != NULL)
afree(ldest, ATEMP);
afree(ldest, ATEMP);
afree(ipath, ATEMP);
return (Xclose(xs, xp));
notfound:
/* save; freeing memory might trash it */
llen = errno;
if (ldest != NULL)
afree(ldest, ATEMP);
afree(ldest, ATEMP);
afree(ipath, ATEMP);
Xfree(xs, xp);
errno = llen;

17
mksh.1
View File

@ -1,9 +1,9 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.379 2015/08/13 22:09:10 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.380 2015/09/05 19:19:08 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,
.\" 2010, 2011, 2012, 2013, 2014, 2015
.\" Thorsten “mirabilos” Glaser <tg@mirbsd.org>
.\" mirabilos <tg@mirbsd.org>
.\"
.\" Provided that these terms and disclaimer and all copyright notices
.\" are retained or reproduced in an accompanying document, permission
@ -74,7 +74,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
.Dd $Mdocdate: August 13 2015 $
.Dd $Mdocdate: September 5 2015 $
.\"
.\" Check which macro package we use, and do other -mdoc setup.
.\"
@ -6394,7 +6394,7 @@ contains the system and suid profile.
.An -nosplit
.Nm "The MirBSD Korn Shell"
is developed by
.An Thorsten Glaser Aq tg@mirbsd.org
.An mirabilos Aq tg@mirbsd.org
and currently maintained as part of The MirOS Project.
This shell is based on the public domain 7th edition Bourne shell clone by
.An Charles Forsyth ,
@ -6427,10 +6427,11 @@ The complete legalese is at:
.Pa https://www.mirbsd.org/TaC\-mksh.txt
.\"
.\" This boils down to: feel free to use mksh.ico as application icon
.\" or shortcut for mksh or mksh/Win32; distro patches are ok (but we
.\" request they amend $KSH_VERSION when modifying mksh). Authors are
.\" Marshall Kirk McKusick (UCB), Rick Collette (ekkoBSD), Thorsten
.\" Glaser, Benny Siegert (MirBSD), Michael Langguth (mksh/Win32).
.\" or shortcut for mksh or mksh/Win32 or OS/2; distro patches are ok
.\" (but we request they amend $KSH_VERSION when modifying mksh).
.\" Authors are Marshall Kirk McKusick (UCB), Rick Collette (ekkoBSD),
.\" mirabilos, Benny Siegert (MirBSD), Michael Langguth (mksh/Win32),
.\" KO Myung-Hun (mksh for OS/2).
.\"
.\" As far as MirBSD is concerned, the files themselves are free
.\" to modification and distribution under BSD/MirOS Licence, the

9
sh.h
View File

@ -2,7 +2,7 @@
/* $OpenBSD: shf.h,v 1.6 2005/12/11 18:53:51 deraadt Exp $ */
/* $OpenBSD: table.h,v 1.8 2012/02/19 07:52:30 otto Exp $ */
/* $OpenBSD: tree.h,v 1.10 2005/03/28 21:28:22 deraadt Exp $ */
/* $OpenBSD: expand.h,v 1.6 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: expand.h,v 1.7 2015/09/01 13:12:31 tedu Exp $ */
/* $OpenBSD: lex.h,v 1.13 2013/03/03 19:11:34 guenther Exp $ */
/* $OpenBSD: proto.h,v 1.35 2013/09/04 15:49:19 millert Exp $ */
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
@ -11,7 +11,7 @@
/*-
* Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -172,9 +172,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.741 2015/08/13 22:06:23 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.744 2015/09/06 19:47:00 tg Exp $");
#endif
#define MKSH_VERSION "R51 2015/08/13"
#define MKSH_VERSION "R51 2015/09/06"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES
@ -1454,6 +1454,7 @@ struct ioword {
#define DOTCOMEXEC BIT(11) /* not an eval flag, used by sh -c hack */
#define DOSCALAR BIT(12) /* change field handling to non-list context */
#define DOHEREDOC BIT(13) /* change scalar handling to heredoc body */
#define DOHERESTR BIT(14) /* append a newline char */
#define X_EXTRA 20 /* this many extra bytes in X string */

4
shf.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011,
* 2012, 2013, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -25,7 +25,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.66 2015/07/09 20:52:43 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.67 2015/09/05 19:19:11 tg Exp $");
/* flags to shf_emptybuf() */
#define EB_READSW 0x01 /* about to switch to reading */

View File

@ -1,6 +1,6 @@
/*-
* Copyright (c) 2006, 2008, 2009, 2013
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@ -18,7 +18,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/strlcpy.c,v 1.8 2013/11/05 22:10:15 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/strlcpy.c,v 1.9 2015/09/05 19:19:11 tg Exp $");
/*
* Copy src to string dst of size siz. At most siz-1 characters

26
syn.c
View File

@ -1,9 +1,9 @@
/* $OpenBSD: syn.c,v 1.29 2013/06/03 18:40:05 jca Exp $ */
/* $OpenBSD: syn.c,v 1.30 2015/09/01 13:12:31 tedu Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.101 2015/04/29 20:07:35 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.104 2015/09/06 19:47:01 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */
@ -172,6 +172,8 @@ c_list(bool multi)
return (t);
}
static const char IONDELIM_delim[] = { CHAR, '<', CHAR, '<', EOS };
static struct ioword *
synio(int cf)
{
@ -189,15 +191,19 @@ synio(int cf)
return (NULL);
ACCEPT;
iop = yylval.iop;
if (iop->ioflag & IONDELIM)
goto gotnulldelim;
ishere = (iop->ioflag & IOTYPE) == IOHERE;
musthave(LWORD, ishere ? HEREDELIM : 0);
if (iop->ioflag & IOHERESTR) {
musthave(LWORD, 0);
} else if (ishere && tpeek(HEREDELIM) == '\n') {
ACCEPT;
yylval.cp = wdcopy(IONDELIM_delim, ATEMP);
iop->ioflag |= IOEVAL | IONDELIM;
} else
musthave(LWORD, ishere ? HEREDELIM : 0);
if (ishere) {
iop->delim = yylval.cp;
if (*ident != 0) {
if (*ident != 0 && !(iop->ioflag & IOHERESTR)) {
/* unquoted */
gotnulldelim:
iop->ioflag |= IOEVAL;
}
if (herep > &heres[HERES - 1])
@ -822,8 +828,8 @@ initkeywords(void)
static void
syntaxerr(const char *what)
{
/* 2<<- is the longest redirection, I think */
char redir[6];
/* 23<<- is the longest redirection, I think */
char redir[8];
const char *s;
struct tokeninfo const *tt;
int c;

29
tree.c
View File

@ -1,9 +1,9 @@
/* $OpenBSD: tree.c,v 1.20 2012/06/27 07:17:19 otto Exp $ */
/* $OpenBSD: tree.c,v 1.21 2015/09/01 13:12:31 tedu Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.74 2015/08/13 20:54:03 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.77 2015/09/06 19:47:01 tg Exp $");
#define INDENT 8
@ -226,7 +226,6 @@ ptree(struct op *t, int indent, struct shf *shf)
shf_putc('\n', shf);
shf_puts(iop->heredoc, shf);
fptreef(shf, indent, "%s",
iop->ioflag & IONDELIM ? "<<" :
evalstr(iop->delim, 0));
need_nl = true;
}
@ -265,6 +264,8 @@ pioact(struct shf *shf, struct ioword *iop)
shf_puts("<<", shf);
if (flag & IOSKIP)
shf_putc('-', shf);
else if (flag & IOHERESTR)
shf_putc('<', shf);
break;
case IOCAT:
shf_puts(">>", shf);
@ -283,17 +284,15 @@ pioact(struct shf *shf, struct ioword *iop)
}
/* name/delim are NULL when printing syntax errors */
if (type == IOHERE) {
if (iop->delim)
if (iop->delim && !(iop->ioflag & IONDELIM))
wdvarput(shf, iop->delim, 0, WDS_TPUTS);
if (flag & IOHERESTR)
shf_putc(' ', shf);
} else if (iop->name) {
if (flag & IONAMEXP)
print_value_quoted(shf, iop->name);
else
wdvarput(shf, iop->name, 0, WDS_TPUTS);
shf_putc(' ', shf);
}
shf_putc(' ', shf);
prevent_semicolon = false;
}
@ -696,8 +695,7 @@ tfree(struct op *t, Area *ap)
if (t == NULL)
return;
if (t->str != NULL)
afree(t->str, ap);
afree(t->str, ap);
if (t->vars != NULL) {
for (w = t->vars; *w != NULL; w++)
@ -732,12 +730,9 @@ iofree(struct ioword **iow, Area *ap)
iop = iow;
while ((p = *iop++) != NULL) {
if (p->name != NULL)
afree(p->name, ap);
if (p->delim != NULL)
afree(p->delim, ap);
if (p->heredoc != NULL)
afree(p->heredoc, ap);
afree(p->name, ap);
afree(p->delim, ap);
afree(p->heredoc, ap);
afree(p, ap);
}
afree(iow, ap);
@ -936,7 +931,7 @@ dumpioact(struct shf *shf, struct op *t)
DB(IOHERESTR)
DB(IONDELIM)
shf_fprintf(shf, ",unit=%d", (int)iop->unit);
if (iop->delim) {
if (iop->delim && !(iop->ioflag & IONDELIM)) {
shf_puts(",delim<", shf);
dumpwdvar(shf, iop->delim);
shf_putc('>', shf);

27
var.c
View File

@ -1,9 +1,9 @@
/* $OpenBSD: var.c,v 1.41 2015/04/17 17:20:41 deraadt Exp $ */
/* $OpenBSD: var.c,v 1.43 2015/09/01 13:12:31 tedu Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -28,7 +28,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.193 2015/07/10 19:36:38 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.194 2015/09/05 19:19:12 tg Exp $");
/*-
* Variables
@ -715,8 +715,7 @@ exportprep(struct tbl *vp, const char *val)
/* offset to value */
vp->type = xp - vp->val.s;
memcpy(xp, val, vallen);
if (op != NULL)
afree(op, vp->areap);
afree(op, vp->areap);
}
/*
@ -954,8 +953,7 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
t->type = 0;
}
}
if (free_me)
afree(free_me, t->areap);
afree(free_me, t->areap);
}
}
if (!ok)
@ -981,8 +979,7 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
/* setstr can't fail (readonly check already done) */
setstr(vp, val, KSH_RETURN_ERROR | 0x4);
if (tval != NULL)
afree(tval, ATEMP);
afree(tval, ATEMP);
}
/* only x[0] is ever exported, so use vpbase */
@ -1279,18 +1276,15 @@ setspec(struct tbl *vp)
ifs0 = *s;
return;
case V_PATH:
if (path)
afree(path, APERM);
afree(path, APERM);
s = str_val(vp);
strdupx(path, s, APERM);
/* clear tracked aliases */
flushcom(true);
return;
case V_TMPDIR:
if (tmpdir) {
afree(tmpdir, APERM);
tmpdir = NULL;
}
afree(tmpdir, APERM);
tmpdir = NULL;
/*
* Use tmpdir iff it is an absolute path, is writable
* and searchable and is a directory...
@ -1399,8 +1393,7 @@ unsetspec(struct tbl *vp)
ifs0 = ' ';
break;
case V_PATH:
if (path)
afree(path, APERM);
afree(path, APERM);
strdupx(path, def_path, APERM);
/* clear tracked aliases */
flushcom(true);