inferlab_runtime/shell.rs
1//! POSIX shell text encoding for rendered scripts and ssh argv.
2
3use std::path::Path;
4
5pub fn shell_quote_path(path: &Path) -> String {
6 shell_quote(&path.to_string_lossy())
7}
8
9pub fn shell_quote(value: &str) -> String {
10 format!("'{}'", value.replace('\'', "'\"'\"'"))
11}
12
13#[cfg(test)]
14mod tests {
15 use super::*;
16
17 #[test]
18 fn shell_quote_preserves_single_quotes() {
19 assert_eq!(shell_quote("a'b"), "'a'\"'\"'b'");
20 }
21}