remove unneeded shell option from cpp-subprocess

We don't use this option and it's not supported on Windows anyways,
so we can get as well rid of it.
This commit is contained in:
Sebastian Falbesoner 2024-04-12 01:42:57 +02:00
parent c7567d9223
commit 633e45b2e2

View File

@ -431,26 +431,6 @@ namespace util
}
/*!
* Function: join
* Parameters:
* [in] vec : Vector of strings which needs to be joined to form
* a single string with words separated by a separator char.
* [in] sep : String used to separate 2 words in the joined string.
* Default constructed to ' ' (space).
* [out] string: Joined string.
*/
static inline
std::string join(const std::vector<std::string>& vec,
const std::string& sep = " ")
{
std::string res;
for (auto& elem : vec) res.append(elem + sep);
res.erase(--res.end());
return res;
}
#ifndef __USING_WINDOWS__
/*!
* Function: set_clo_on_exec
@ -696,11 +676,6 @@ struct session_leader {
bool leader_ = false;
};
struct shell {
explicit shell(bool s): shell_(s) {}
bool shell_ = false;
};
/*!
* Base class for all arguments involving string value.
*/
@ -1011,7 +986,6 @@ struct ArgumentDeducer
void set_option(bufsize&& bsiz);
void set_option(environment&& env);
void set_option(defer_spawn&& defer);
void set_option(shell&& sh);
void set_option(input&& inp);
void set_option(output&& out);
void set_option(error&& err);
@ -1350,7 +1324,6 @@ private:
bool defer_process_start_ = false;
bool close_fds_ = false;
bool has_preexec_fn_ = false;
bool shell_ = false;
bool session_leader_ = false;
std::string exe_name_;
@ -1492,10 +1465,6 @@ inline void Popen::kill(int sig_num)
inline void Popen::execute_process() noexcept(false)
{
#ifdef __USING_WINDOWS__
if (this->shell_) {
throw OSError("shell not currently supported on windows", 0);
}
void* environment_string_table_ptr = nullptr;
env_vector_t environment_string_vector;
if(this->env_.size()){
@ -1588,14 +1557,6 @@ inline void Popen::execute_process() noexcept(false)
int err_rd_pipe, err_wr_pipe;
std::tie(err_rd_pipe, err_wr_pipe) = util::pipe_cloexec();
if (shell_) {
auto new_cmd = util::join(vargs_);
vargs_.clear();
vargs_.insert(vargs_.begin(), {"/bin/sh", "-c"});
vargs_.push_back(new_cmd);
populate_c_argv();
}
if (exe_name_.length()) {
vargs_.insert(vargs_.begin(), exe_name_);
populate_c_argv();
@ -1678,10 +1639,6 @@ namespace detail {
popen_->defer_process_start_ = defer.defer;
}
inline void ArgumentDeducer::set_option(shell&& sh) {
popen_->shell_ = sh.shell_;
}
inline void ArgumentDeducer::set_option(session_leader&& sleader) {
popen_->session_leader_ = sleader.leader_;
}