fix env variable load and subst order
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 1m24s
Build-Test-Publish / build (linux/arm64) (push) Successful in 4m16s

This commit is contained in:
2025-10-03 18:56:04 +13:00
parent e001413844
commit af75b0b4ac
13 changed files with 124 additions and 64 deletions

View File

@@ -3,6 +3,7 @@
#include <string>
#include <map>
#include "ordered_env.hpp"
namespace dropshell {
@@ -44,7 +45,7 @@ class sSSHInfo {
std::string user_dir; // dropshell directory for the user.
};
bool execute_local_command(std::string directory_to_run_in, std::string command_to_run, const std::map<std::string, std::string> & env_vars, std::string * output = nullptr, cMode mode = cMode::Defaults);
bool execute_local_command(std::string directory_to_run_in, std::string command_to_run, const ordered_env_vars& env_vars, std::string * output = nullptr, cMode mode = cMode::Defaults);
bool execute_ssh_command(const sSSHInfo & ssh_info, const sCommand & remote_command, cMode mode = cMode::Defaults, std::string * output = nullptr);
@@ -54,17 +55,17 @@ bool execute_ssh_command(const sSSHInfo & ssh_info, const sCommand & remote_comm
// class to hold a command to run on the remote server.
class sCommand {
public:
sCommand(std::string directory_to_run_in, std::string command_to_run, const std::map<std::string, std::string> & env_vars) :
sCommand(std::string directory_to_run_in, std::string command_to_run, const ordered_env_vars& env_vars) :
mDir(directory_to_run_in), mCmd(command_to_run), mVars(env_vars) {}
std::string get_directory_to_run_in() const { return mDir; }
std::string get_command_to_run() const { return mCmd; }
const std::map<std::string, std::string>& get_env_vars() const { return mVars; }
const ordered_env_vars& get_env_vars() const { return mVars; }
void add_env_var(const std::string& key, const std::string& value) { mVars.emplace_back(key, value); }
void add_env_var(const std::string& key, const std::string& value) { mVars[key] = value; }
bool empty() const { return mCmd.empty(); }
std::string construct_cmd(std::string bb64path) const;
private:
@@ -73,7 +74,7 @@ class sCommand {
private:
std::string mDir;
std::string mCmd;
std::map<std::string, std::string> mVars;
ordered_env_vars mVars;
};
bool EXITSTATUSCHECK(int ret);