Skip to main content

quote

Function quote 

Source
pub fn quote(value: &str) -> String
Expand description

Quote a value for safe shell usage

This function quotes strings appropriately for use in shell commands, handling special characters and edge cases.

ยงExamples

use command_stream::quote::quote;

// Safe characters are passed through unchanged
assert_eq!(quote("hello"), "hello");
assert_eq!(quote("/path/to/file"), "/path/to/file");

// Special characters are quoted
assert_eq!(quote("hello world"), "'hello world'");

// Single quotes in strings are escaped
assert_eq!(quote("it's"), "'it'\\''s'");

// Empty strings are quoted
assert_eq!(quote(""), "''");