mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
parser.cpp: Put off initialization of new_io until mode is known
This commit is contained in:
parent
165068c81d
commit
4e672427bc
1 changed files with 10 additions and 11 deletions
21
parser.cpp
21
parser.cpp
|
@ -1518,13 +1518,12 @@ void parser_t::parse_job_argument_list(process_t *p,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_io.reset(new io_data_t);
|
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
new_io->fd = fish_wcstoi(tok_last(tok),
|
int fd = fish_wcstoi(tok_last(tok),
|
||||||
&end,
|
&end,
|
||||||
10);
|
10);
|
||||||
if (new_io->fd < 0 || errno || *end)
|
if (fd < 0 || errno || *end)
|
||||||
{
|
{
|
||||||
error(SYNTAX_ERROR,
|
error(SYNTAX_ERROR,
|
||||||
tok_get_pos(tok),
|
tok_get_pos(tok),
|
||||||
|
@ -1575,25 +1574,25 @@ void parser_t::parse_job_argument_list(process_t *p,
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case TOK_REDIRECT_APPEND:
|
case TOK_REDIRECT_APPEND:
|
||||||
new_io->io_mode = IO_FILE;
|
new_io.reset(new io_data_t(IO_FILE, fd));
|
||||||
new_io->param2.flags = O_CREAT | O_APPEND | O_WRONLY;
|
new_io->param2.flags = O_CREAT | O_APPEND | O_WRONLY;
|
||||||
new_io->set_filename(target);
|
new_io->set_filename(target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOK_REDIRECT_OUT:
|
case TOK_REDIRECT_OUT:
|
||||||
new_io->io_mode = IO_FILE;
|
new_io.reset(new io_data_t(IO_FILE, fd));
|
||||||
new_io->param2.flags = O_CREAT | O_WRONLY | O_TRUNC;
|
new_io->param2.flags = O_CREAT | O_WRONLY | O_TRUNC;
|
||||||
new_io->set_filename(target);
|
new_io->set_filename(target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOK_REDIRECT_NOCLOB:
|
case TOK_REDIRECT_NOCLOB:
|
||||||
new_io->io_mode = IO_FILE;
|
new_io.reset(new io_data_t(IO_FILE, fd));
|
||||||
new_io->param2.flags = O_CREAT | O_EXCL | O_WRONLY;
|
new_io->param2.flags = O_CREAT | O_EXCL | O_WRONLY;
|
||||||
new_io->set_filename(target);
|
new_io->set_filename(target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOK_REDIRECT_IN:
|
case TOK_REDIRECT_IN:
|
||||||
new_io->io_mode = IO_FILE;
|
new_io.reset(new io_data_t(IO_FILE, fd));
|
||||||
new_io->param2.flags = O_RDONLY;
|
new_io->param2.flags = O_RDONLY;
|
||||||
new_io->set_filename(target);
|
new_io->set_filename(target);
|
||||||
break;
|
break;
|
||||||
|
@ -1602,13 +1601,13 @@ void parser_t::parse_job_argument_list(process_t *p,
|
||||||
{
|
{
|
||||||
if (target == L"-")
|
if (target == L"-")
|
||||||
{
|
{
|
||||||
new_io->io_mode = IO_CLOSE;
|
new_io.reset(new io_data_t(IO_CLOSE, fd));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wchar_t *end;
|
wchar_t *end;
|
||||||
|
|
||||||
new_io->io_mode = IO_FD;
|
new_io.reset(new io_data_t(IO_FD, fd));
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
new_io->param1.old_fd = fish_wcstoi(target.c_str(), &end, 10);
|
new_io->param1.old_fd = fish_wcstoi(target.c_str(), &end, 10);
|
||||||
|
|
Loading…
Reference in a new issue