fix cd bug in ds_run, and fix ds ssh so it doesnt hang process
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 48s
Build-Test-Publish / build (linux/arm64) (push) Successful in 3m10s

This commit is contained in:
j
2026-01-02 22:02:46 +13:00
parent b20bf7476c
commit 767692160d
4 changed files with 34 additions and 4 deletions

View File

@@ -56,6 +56,23 @@ namespace dropshell
}
}
// ----------------------------------------------------------------------------------------------------------
// execute_local_command_replace - replaces current process with the command (never returns on success)
// ----------------------------------------------------------------------------------------------------------
bool execute_local_command_replace(const std::string &full_command)
{
if (full_command.empty())
return false;
// Use exec to replace the current process with a shell running the command
// This means dropshell exits immediately and ssh (or whatever) takes over
execlp("/bin/bash", "bash", "-c", full_command.c_str(), nullptr);
// If we get here, exec failed
perror("exec failed");
return false;
}
// ----------------------------------------------------------------------------------------------------------
// execute_local_command
// ----------------------------------------------------------------------------------------------------------
@@ -117,6 +134,18 @@ namespace dropshell
{
sCommand command(directory_to_run_in, command_to_run, env_vars);
if (hasFlag(mode, cMode::ReplaceProcess))
{
ASSERT(output == nullptr, "ReplaceProcess mode and an output string cannot be used together");
// For ReplaceProcess, run the command directly without bb64 wrapping
// (the caller is responsible for constructing the full command)
std::string full_cmd = command_to_run;
if (!directory_to_run_in.empty())
full_cmd = "cd " + quote(directory_to_run_in) + " && " + full_cmd;
return execute_local_command_replace(full_cmd);
// Note: execute_local_command_replace never returns on success
}
if (hasFlag(mode, cMode::Interactive))
{
ASSERT(output == nullptr, "Interactive mode and an output string cannot be used together");