Fix distant client shell choosing appropriate default; update CHANGELOG

pull/137/head
Chip Senkbeil 2 years ago
parent 6c4318baa0
commit 04b20d1348
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- `distant client shell` will now choose between `/bin/sh` and `cmd.exe` as the
default shell based on the family returned by a system info request
- `distant client shell` properly terminates master pty when the shell exits,
resolving the hanging that occurred for Windows `cmd.exe` and
`powershell.exe` upon exit
## [0.18.0] - 2022-08-18
### Changed

@ -2,7 +2,7 @@ use super::{link::RemoteProcessLink, CliError, CliResult};
use anyhow::Context;
use distant_core::{
data::{Environment, PtySize},
DistantChannel, RemoteCommand,
DistantChannel, DistantChannelExt, RemoteCommand,
};
use log::*;
use std::time::Duration;
@ -22,7 +22,7 @@ impl Shell {
}
pub async fn spawn(
self,
mut self,
cmd: impl Into<Option<String>>,
mut environment: Environment,
persist: bool,
@ -32,7 +32,23 @@ impl Shell {
environment.insert("TERM".to_string(), "xterm-256color".to_string());
}
let cmd = cmd.into().unwrap_or_else(|| "/bin/sh".to_string());
// Use provided shell, or determine remote operating system to pick a shell
let cmd = match cmd.into() {
Some(cmd) => cmd,
None => {
let system_info = self
.0
.system_info()
.await
.context("Failed to detect remote operating system")?;
if system_info.family.eq_ignore_ascii_case("windows") {
"cmd.exe".to_string()
} else {
"/bin/sh".to_string()
}
}
};
let mut proc = RemoteCommand::new()
.persist(persist)
.environment(environment)

Loading…
Cancel
Save