tweak some iop/conservative_fds-related things I picked up while thinking lksh
This commit is contained in:
parent
22fff17047
commit
fc48729336
6
eval.c
6
eval.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.173 2015/10/09 17:48:48 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.174 2015/10/09 19:29:47 tg Exp $");
|
||||
|
||||
/*
|
||||
* string expansion
|
||||
@ -1334,8 +1334,8 @@ comsub(Expand *xp, const char *cp, int fn MKSH_A_UNUSED)
|
||||
if ((io->ioflag & IOTYPE) != IOREAD)
|
||||
errorf("%s: %s", "funny $() command",
|
||||
snptreef(NULL, 32, "%R", io));
|
||||
shf = shf_open(name = evalstr(io->name, DOTILDE), O_RDONLY, 0,
|
||||
SHF_MAPHI|SHF_CLEXEC);
|
||||
shf = shf_open(name = evalstr(io->ioname, DOTILDE), O_RDONLY,
|
||||
0, SHF_MAPHI | SHF_CLEXEC);
|
||||
if (shf == NULL)
|
||||
warningf(!Flag(FTALKING), "%s: %s %s: %s", name,
|
||||
"can't open", "$(<...) input", cstrerror(errno));
|
||||
|
6
exec.c
6
exec.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.166 2015/10/09 17:48:49 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.167 2015/10/09 19:29:48 tg Exp $");
|
||||
|
||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"
|
||||
@ -1369,7 +1369,7 @@ static int
|
||||
iosetup(struct ioword *iop, struct tbl *tp)
|
||||
{
|
||||
int u = -1;
|
||||
char *cp = iop->name;
|
||||
char *cp = iop->ioname;
|
||||
int iotype = iop->ioflag & IOTYPE;
|
||||
bool do_open = true, do_close = false;
|
||||
int flags = 0;
|
||||
@ -1381,7 +1381,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
||||
|
||||
/* Used for tracing and error messages to print expanded cp */
|
||||
iotmp = *iop;
|
||||
iotmp.name = (iotype == IOHERE) ? NULL : cp;
|
||||
iotmp.ioname = (iotype == IOHERE) ? NULL : cp;
|
||||
iotmp.ioflag |= IONAMEXP;
|
||||
|
||||
if (Flag(FXTRACE)) {
|
||||
|
4
lex.c
4
lex.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.211 2015/10/09 17:48:51 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.212 2015/10/09 19:29:48 tg Exp $");
|
||||
|
||||
/*
|
||||
* states while lexing word
|
||||
@ -951,7 +951,7 @@ yylex(int cf)
|
||||
ungetsc(c2);
|
||||
}
|
||||
|
||||
iop->name = NULL;
|
||||
iop->ioname = NULL;
|
||||
iop->delim = NULL;
|
||||
iop->heredoc = NULL;
|
||||
/* free word */
|
||||
|
4
sh.h
4
sh.h
@ -172,7 +172,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.747 2015/10/09 17:48:52 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.748 2015/10/09 19:29:49 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R51 2015/10/05"
|
||||
|
||||
@ -1398,7 +1398,7 @@ struct op {
|
||||
* IO redirection
|
||||
*/
|
||||
struct ioword {
|
||||
char *name; /* filename (unused if heredoc) */
|
||||
char *ioname; /* filename (unused if heredoc) */
|
||||
char *delim; /* delimiter for <<, <<- */
|
||||
char *heredoc; /* content of heredoc */
|
||||
unsigned short ioflag; /* action (below) */
|
||||
|
10
syn.c
10
syn.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.105 2015/10/09 17:48:53 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.106 2015/10/09 19:29:50 tg Exp $");
|
||||
|
||||
struct nesting_state {
|
||||
int start_token; /* token than began nesting (eg, FOR) */
|
||||
@ -210,18 +210,22 @@ synio(int cf)
|
||||
yyerror("too many %ss\n", "<<");
|
||||
*herep++ = iop;
|
||||
} else
|
||||
iop->name = yylval.cp;
|
||||
iop->ioname = yylval.cp;
|
||||
|
||||
if (iop->ioflag & IOBASH) {
|
||||
char *cp;
|
||||
|
||||
nextiop = alloc(sizeof(*iop), ATEMP);
|
||||
nextiop->name = cp = alloc(5, ATEMP);
|
||||
#ifdef MKSH_CONSERVATIVE_FDS
|
||||
nextiop->ioname = cp = alloc(3, ATEMP);
|
||||
#else
|
||||
nextiop->ioname = cp = alloc(5, ATEMP);
|
||||
|
||||
if (iop->unit > 9) {
|
||||
*cp++ = CHAR;
|
||||
*cp++ = digits_lc[iop->unit / 10];
|
||||
}
|
||||
#endif
|
||||
*cp++ = CHAR;
|
||||
*cp++ = digits_lc[iop->unit % 10];
|
||||
*cp = EOS;
|
||||
|
22
tree.c
22
tree.c
@ -3,7 +3,7 @@
|
||||
/*-
|
||||
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
* 2011, 2012, 2013, 2015
|
||||
* mirabilos <tg@mirbsd.org>
|
||||
* mirabilos <m@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.77 2015/09/06 19:47:01 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.78 2015/10/09 19:29:50 tg Exp $");
|
||||
|
||||
#define INDENT 8
|
||||
|
||||
@ -286,11 +286,11 @@ pioact(struct shf *shf, struct ioword *iop)
|
||||
if (type == IOHERE) {
|
||||
if (iop->delim && !(iop->ioflag & IONDELIM))
|
||||
wdvarput(shf, iop->delim, 0, WDS_TPUTS);
|
||||
} else if (iop->name) {
|
||||
} else if (iop->ioname) {
|
||||
if (flag & IONAMEXP)
|
||||
print_value_quoted(shf, iop->name);
|
||||
print_value_quoted(shf, iop->ioname);
|
||||
else
|
||||
wdvarput(shf, iop->name, 0, WDS_TPUTS);
|
||||
wdvarput(shf, iop->ioname, 0, WDS_TPUTS);
|
||||
}
|
||||
shf_putc(' ', shf);
|
||||
prevent_semicolon = false;
|
||||
@ -672,8 +672,8 @@ iocopy(struct ioword **iow, Area *ap)
|
||||
q = alloc(sizeof(struct ioword), ap);
|
||||
ior[i] = q;
|
||||
*q = *p;
|
||||
if (p->name != NULL)
|
||||
q->name = wdcopy(p->name, ap);
|
||||
if (p->ioname != NULL)
|
||||
q->ioname = wdcopy(p->ioname, ap);
|
||||
if (p->delim != NULL)
|
||||
q->delim = wdcopy(p->delim, ap);
|
||||
if (p->heredoc != NULL)
|
||||
@ -730,7 +730,7 @@ iofree(struct ioword **iow, Area *ap)
|
||||
|
||||
iop = iow;
|
||||
while ((p = *iop++) != NULL) {
|
||||
afree(p->name, ap);
|
||||
afree(p->ioname, ap);
|
||||
afree(p->delim, ap);
|
||||
afree(p->heredoc, ap);
|
||||
afree(p, ap);
|
||||
@ -936,13 +936,13 @@ dumpioact(struct shf *shf, struct op *t)
|
||||
dumpwdvar(shf, iop->delim);
|
||||
shf_putc('>', shf);
|
||||
}
|
||||
if (iop->name) {
|
||||
if (iop->ioname) {
|
||||
if (iop->ioflag & IONAMEXP) {
|
||||
shf_puts(",name=", shf);
|
||||
print_value_quoted(shf, iop->name);
|
||||
print_value_quoted(shf, iop->ioname);
|
||||
} else {
|
||||
shf_puts(",name<", shf);
|
||||
dumpwdvar(shf, iop->name);
|
||||
dumpwdvar(shf, iop->ioname);
|
||||
shf_putc('>', shf);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user