Skip to main content

scan_quote_context

Function scan_quote_context 

Source
pub fn scan_quote_context(text: &str, context: QuoteContext) -> QuoteContext
Expand description

Advance the shell quoting state across a literal chunk of a template.

Only the template’s own text is scanned - interpolated values never change the state, which is exactly why they cannot break out of their quotes.

§Examples

use command_stream::quote::{scan_quote_context, QuoteContext};

assert_eq!(scan_quote_context("echo ", QuoteContext::Unquoted), QuoteContext::Unquoted);
assert_eq!(scan_quote_context("bash -c \"", QuoteContext::Unquoted), QuoteContext::Double);
assert_eq!(scan_quote_context("echo '", QuoteContext::Unquoted), QuoteContext::Single);