Skip to main content

escape_for_single_quotes

Function escape_for_single_quotes 

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

Escape a value so it can sit inside '...' as literal text.

A single quote is emitted as '\'' - close, escaped quote, reopen - which is the standard POSIX idiom.

ยงExamples

use command_stream::quote::escape_for_single_quotes;

assert_eq!(escape_for_single_quotes("plain $text"), "plain $text");
assert_eq!(escape_for_single_quotes("it's"), "it'\\''s");