fix cd bug in ds_run, and fix ds ssh so it doesnt hang process
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user