From d60b7364bc996357eefbd3884f19fc3038b449c5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 6 May 2025 21:42:36 +1200 Subject: [PATCH] improvement. --- src/utils/execute.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/utils/execute.cpp b/src/utils/execute.cpp index 24afd38..62a6788 100644 --- a/src/utils/execute.cpp +++ b/src/utils/execute.cpp @@ -59,7 +59,13 @@ bool execute_local_command(const sCommand& command, bool silent, bool safe) { cStyle style = safe ? cStyle::Safe : cStyle::Raw; std::string full_cmd = command.construct_cmd(style) + " 2>&1" + (silent ? " > /dev/null" : ""); int ret = system(full_cmd.c_str()); - return EXITSTATUSCHECK(ret); + + bool ok = EXITSTATUSCHECK(ret); + if (!ok) { + std::cerr << "Error: Failed to execute command: " << std::endl; + std::cerr << full_cmd << std::endl; + } + return ok; } bool execute_local_command_and_capture_output(const sCommand& command, std::string &output, bool silent, bool safe) @@ -110,13 +116,7 @@ bool execute_ssh_command(const sSSHInfo &ssh_info, const sCommand &command, cMod ssh_cmd << "ssh -p " << ssh_info.port << " " << (mode & cMode::Interactive ? "-tt " : "") << ssh_info.user << "@" << ssh_info.host; - std::string full_cmd = ssh_cmd.str() + " " + command.get_command_to_run(); - - sCommand ssh_command = { - command.get_directory_to_run_in(), - full_cmd, - command.get_env_vars() - }; + sCommand ssh_command(ssh_cmd.str() + " bash -c " + quote(escapequotes(command.construct_cmd(mode & cMode::SafeCommand ? cStyle::Safe : cStyle::Raw)))); bool rval = execute_local_command(ssh_command, mode, output);