mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 23:02:44 +08:00
Restore correct order of IO redirections
Fixes https://github.com/fish-shell/fish-shell/issues/281
This commit is contained in:
parent
e3ec361552
commit
9145d05397
2
exec.cpp
2
exec.cpp
|
@ -408,7 +408,7 @@ void exec( parser_t &parser, job_t *j )
|
||||||
|
|
||||||
if( ! parser.block_io.empty() )
|
if( ! parser.block_io.empty() )
|
||||||
{
|
{
|
||||||
io_duplicate_append(parser.block_io, j->io);
|
io_duplicate_prepend(parser.block_io, j->io);
|
||||||
}
|
}
|
||||||
|
|
||||||
const io_data_t *input_redirect = NULL;
|
const io_data_t *input_redirect = NULL;
|
||||||
|
|
11
io.cpp
11
io.cpp
|
@ -179,13 +179,14 @@ io_chain_t io_chain_t::duplicate() const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void io_chain_t::duplicate_append(const io_chain_t &src)
|
void io_chain_t::duplicate_prepend(const io_chain_t &src)
|
||||||
{
|
{
|
||||||
this->reserve(this->size() + src.size());
|
/* Prepend a duplicate of src before this. Start by inserting a bunch of NULLs (so we only have to reallocate once) and then replace them. */
|
||||||
|
this->insert(this->begin(), src.size(), NULL);
|
||||||
for (size_t idx = 0; idx < src.size(); idx++)
|
for (size_t idx = 0; idx < src.size(); idx++)
|
||||||
{
|
{
|
||||||
const io_data_t *src_data = src.at(idx);
|
const io_data_t *src_data = src.at(idx);
|
||||||
this->push_back(new io_data_t(*src_data));
|
this->at(idx) = new io_data_t(*src_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,9 +242,9 @@ void io_print(const io_chain_t &chain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void io_duplicate_append( const io_chain_t &src, io_chain_t &dst )
|
void io_duplicate_prepend( const io_chain_t &src, io_chain_t &dst )
|
||||||
{
|
{
|
||||||
return dst.duplicate_append(src);
|
return dst.duplicate_prepend(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
void io_chain_destroy(io_chain_t &chain)
|
void io_chain_destroy(io_chain_t &chain)
|
||||||
|
|
7
io.h
7
io.h
|
@ -124,13 +124,12 @@ public:
|
||||||
|
|
||||||
void remove(const io_data_t *element);
|
void remove(const io_data_t *element);
|
||||||
io_chain_t duplicate() const;
|
io_chain_t duplicate() const;
|
||||||
void duplicate_append(const io_chain_t &src);
|
void duplicate_prepend(const io_chain_t &src);
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
const io_data_t *get_io_for_fd(int fd) const;
|
const io_data_t *get_io_for_fd(int fd) const;
|
||||||
io_data_t *get_io_for_fd(int fd);
|
io_data_t *get_io_for_fd(int fd);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,8 +143,8 @@ io_chain_t io_duplicate(const io_chain_t &chain);
|
||||||
/** Return a shallow copy of the specified chain of redirections that contains only the applicable redirections. That is, if there's multiple redirections for the same fd, only the second one is included. */
|
/** Return a shallow copy of the specified chain of redirections that contains only the applicable redirections. That is, if there's multiple redirections for the same fd, only the second one is included. */
|
||||||
io_chain_t io_unique(const io_chain_t &chain);
|
io_chain_t io_unique(const io_chain_t &chain);
|
||||||
|
|
||||||
/** Appends a copy of the specified 'src' chain of redirections to 'dst.' Uses operator new. */
|
/** Prepends a copy of the specified 'src' chain of redirections to 'dst.' Uses operator new. */
|
||||||
void io_duplicate_append( const io_chain_t &src, io_chain_t &dst );
|
void io_duplicate_prepend( const io_chain_t &src, io_chain_t &dst );
|
||||||
|
|
||||||
/** Destroys an io_chain */
|
/** Destroys an io_chain */
|
||||||
void io_chain_destroy(io_chain_t &chain);
|
void io_chain_destroy(io_chain_t &chain);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user