//! Shared utility functions. /// Escape a string for safe interpolation into a POSIX shell command. /// /// Wraps the input in single quotes and escapes any embedded single quotes /// using the `'\''` technique. This prevents command injection when building /// shell commands from user-supplied values. /// /// # Examples /// /// ``` /// # use wraith_lib::utils::shell_escape; /// assert_eq!(shell_escape("hello"), "'hello'"); /// assert_eq!(shell_escape("it's"), "'it'\\''s'"); /// assert_eq!(shell_escape(";rm -rf /"), "';rm -rf /'"); /// ``` pub fn shell_escape(input: &str) -> String { format!("'{}'", input.replace('\'', "'\\''")) }