Create a [`tokio::process::Command`] that runs `openshell` under a PTY.
(args: &[&str])
| 62 | |
| 63 | /// Create a [`tokio::process::Command`] that runs `openshell` under a PTY. |
| 64 | pub fn openshell_tty_cmd(args: &[&str]) -> tokio::process::Command { |
| 65 | let bin = openshell_bin(); |
| 66 | let mut cmd = tokio::process::Command::new("script"); |
| 67 | |
| 68 | if cfg!(target_os = "macos") { |
| 69 | cmd.arg("-q").arg("/dev/null").arg(bin).args(args); |
| 70 | } else { |
| 71 | let mut shell_command = shell_escape(bin.to_str().expect("openshell path is utf-8")); |
| 72 | for arg in args { |
| 73 | shell_command.push(' '); |
| 74 | shell_command.push_str(&shell_escape(arg)); |
| 75 | } |
| 76 | cmd.arg("-q") |
| 77 | .arg("-e") |
| 78 | .arg("-c") |
| 79 | .arg(shell_command) |
| 80 | .arg("/dev/null"); |
| 81 | } |
| 82 | |
| 83 | cmd.kill_on_drop(true); |
| 84 | cmd |
| 85 | } |
| 86 | |
| 87 | #[cfg(test)] |
| 88 | mod tests { |