Add login shell support by defualt to run distant command on launch

pull/38/head
Chip Senkbeil 3 years ago
parent f6e9195503
commit 160631bc7b
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -408,6 +408,10 @@ pub struct LaunchSubcommand {
#[structopt(short, long)]
pub identity_file: Option<PathBuf>,
/// If specified, will not launch distant using a login shell but instead execute it directly
#[structopt(long)]
pub no_shell: bool,
/// Port to use for sshing into the remote machine
#[structopt(short, long, default_value = "22")]
pub port: u16,

@ -403,7 +403,7 @@ async fn spawn_remote_server(cmd: LaunchSubcommand, _opt: CommonOpt) -> Result<S
cmd.extra_server_args.unwrap_or_default(),
);
let ssh_command = format!(
"{} -o StrictHostKeyChecking=no ssh://{}@{}:{} {} {}",
"{} -o StrictHostKeyChecking=no ssh://{}@{}:{} {} '{}'",
cmd.ssh,
cmd.username,
cmd.host.as_str(),
@ -411,7 +411,12 @@ async fn spawn_remote_server(cmd: LaunchSubcommand, _opt: CommonOpt) -> Result<S
cmd.identity_file
.map(|f| format!("-i {}", f.as_path().display()))
.unwrap_or_default(),
distant_command.trim(),
if cmd.no_shell {
distant_command.trim().to_string()
} else {
// TODO: Do we need to try to escape single quotes here because of extra_server_args?
format!("echo {} | $SHELL -l", distant_command.trim())
},
);
let out = Command::new("sh")
.arg("-c")

Loading…
Cancel
Save