use crate::shell_escape::escape_for_shell;
pub(crate) fn remote_job_log_path(job_id: &str) -> String {
format!("/tmp/.ssh-mcp-job-{job_id}.log")
}
pub(crate) fn build_background_wrapper_script(
job_id: &str,
user_command: &str,
log_path: &str,
) -> String {
let escaped_user_command = escape_for_shell(user_command);
let escaped_log_path = escape_for_shell(log_path);
format!(
"LOG='{escaped_log_path}'; \
printf '%s\n' \"__SSH_MCP_JOB_ID={job_id}\"; \
printf '%s\n' \"__SSH_MCP_PID=$$\"; \
printf '%s\n' \"__SSH_MCP_LOG=$LOG\"; \
exec sh -c 'set +m; {escaped_user_command}'",
)
}