/usr/include/boost/process/detail/posix
NameSizeModeActions
asio_fwd.hpp13420644editdlrm
async_handler.hpp11870644editdlrm
async_in.hpp35410644editdlrm
async_out.hpp57940644editdlrm
async_pipe.hpp113860644editdlrm
basic_cmd.hpp45510644editdlrm
basic_pipe.hpp56600644editdlrm
child_handle.hpp14320644editdlrm
close_in.hpp10530644editdlrm
close_out.hpp17350644editdlrm
cmd.hpp25310644editdlrm
compare_handles.hpp10290644editdlrm
environment.hpp99600644editdlrm
env_init.hpp9790644editdlrm
exe.hpp5690644editdlrm
executor.hpp155410644editdlrm
fd.hpp26210644editdlrm
file_descriptor.hpp18840644editdlrm
file_in.hpp14070644editdlrm
file_out.hpp21980644editdlrm
group_handle.hpp20680644editdlrm
group_ref.hpp10880644editdlrm
handler.hpp17390644editdlrm
handles.hpp39450644editdlrm
io_context_ref.hpp40360644editdlrm
is_running.hpp23040644editdlrm
null_in.hpp13050644editdlrm
null_out.hpp20890644editdlrm
on_exit.hpp10010644editdlrm
pipe_in.hpp23750644editdlrm
pipe_out.hpp30910644editdlrm
search_path.hpp12180644editdlrm
shell_path.hpp8780644editdlrm
sigchld_service.hpp41020644editdlrm
signal.hpp18980644editdlrm
start_dir.hpp10930644editdlrm
terminate.hpp11990644editdlrm
use_vfork.hpp7810644editdlrm
wait_for_exit.hpp66890644editdlrm
wait_group.hpp34230644editdlrm
Edit: /usr/include/boost/process/detail/posix/basic_cmd.hpp (4551B)
// Copyright (c) 2016 Klemens D. Morgenstern // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PROCESS_DETAIL_POSIX_BASIC_CMD_HPP_ #define BOOST_PROCESS_DETAIL_POSIX_BASIC_CMD_HPP_ #include #include #include #include #include #include #include #include namespace boost { namespace process { namespace detail { namespace posix { inline std::string build_cmd_shell(const std::string & exe, std::vector && data) { std::string st = exe; for (auto & arg : data) { boost::replace_all(arg, "\"", "\\\""); auto it = std::find(arg.begin(), arg.end(), ' ');//contains space? if (it != arg.end())//ok, contains spaces. { //the first one is put directly onto the output, //because then I don't have to copy the whole string arg.insert(arg.begin(), '"' ); arg += '"'; //thats the post one. } if (!st.empty())//first one does not need a preceeding space st += ' '; st += arg; } return st ; } inline std::vector build_args(const std::string & data) { std::vector st; typedef std::string::const_iterator itr_t; //normal quotes outside can be stripped, inside ones marked as \" will be replaced. auto make_entry = [](const itr_t & begin, const itr_t & end) { std::string data; if ((*begin == '"') && (*(end-1) == '"')) data.assign(begin+1, end-1); else data.assign(begin, end); boost::replace_all(data, "\\\"", "\""); return data; }; bool in_quote = false; auto part_beg = data.cbegin(); auto itr = data.cbegin(); for (; itr != data.cend(); itr++) { if (*itr == '"') in_quote ^= true; if (!in_quote && (*itr == ' ')) { //alright, got a space if ((itr != data.cbegin()) && (*(itr -1) != ' ' )) st.push_back(make_entry(part_beg, itr)); part_beg = itr+1; } } if (part_beg != itr) st.emplace_back(make_entry(part_beg, itr)); return st; } template struct exe_cmd_init; template<> struct exe_cmd_init : boost::process::detail::api::handler_base_ext { exe_cmd_init(const exe_cmd_init & ) = delete; exe_cmd_init(exe_cmd_init && ) = default; exe_cmd_init(std::string && exe, std::vector && args) : exe(std::move(exe)), args(std::move(args)) {}; template void on_setup(Executor& exec) { if (exe.empty()) //cmd style { exec.exe = args.front().c_str(); exec.cmd_style = true; } else exec.exe = &exe.front(); cmd_impl = make_cmd(); exec.cmd_line = cmd_impl.data(); } static exe_cmd_init exe_args(std::string && exe, std::vector && args) {return exe_cmd_init(std::move(exe), std::move(args));} static exe_cmd_init cmd (std::string && cmd) { auto args = build_args(cmd); return exe_cmd_init({}, std::move(args)); } static exe_cmd_init exe_args_shell(std::string&& exe, std::vector && args) { auto cmd = build_cmd_shell(std::move(exe), std::move(args)); std::vector args_ = {"-c", std::move(cmd)}; std::string sh = shell().string(); return exe_cmd_init(std::move(sh), std::move(args_)); } static exe_cmd_init cmd_shell(std::string&& cmd) { std::vector args = {"-c", "\"" + cmd + "\""}; std::string sh = shell().string(); return exe_cmd_init( std::move(sh), {std::move(args)}); } private: inline std::vector make_cmd(); std::string exe; std::vector args; std::vector cmd_impl; }; std::vector exe_cmd_init::make_cmd() { std::vector vec; if (!exe.empty()) vec.push_back(&exe.front()); if (!args.empty()) { for (auto & v : args) vec.push_back(&v.front()); } vec.push_back(nullptr); return vec; } }}}} #endif