shell

Shell Word Splitting and Escaping

Functions

FunctionDescription
shell_needs_escapeInternal: does this byte need escaping in a shell context?
shell_escapeEscape a string for safe shell use with backslashes. Returns output length.
shell_quoteSingle-quote a string (strongest quoting). Handles embedded single quotes wit…
shell_joinJoin multiple words into a single shell-safe string with spaces. words: array…
shell_splitSplit a shell string into words respecting quotes. Stores offsets and lengths…

Details

shell_needs_escape

fn shell_needs_escape(ch: i64) -> i64

Internal: does this byte need escaping in a shell context?

shell_escape

fn shell_escape(src: &i8, len: i64, dst: &i8) -> i64

Escape a string for safe shell use with backslashes. Returns output length.

shell_quote

fn shell_quote(src: &i8, len: i64, dst: &i8) -> i64

Single-quote a string (strongest quoting). Handles embedded single quotes with ‘'’ sequence.

shell_join

fn shell_join(words: &i64, lengths: &i64, count: i64, dst: &i8) -> i64

Join multiple words into a single shell-safe string with spaces. words: array of &i8 pointers, lengths: array of i64.

shell_split

fn shell_split(src: &i8, len: i64, offsets: &i64, lengths: &i64) -> i64

Split a shell string into words respecting quotes. Stores offsets and lengths into provided arrays. Returns number of words found.