Skip to main content

shell_quote

Function shell_quote 

Source
pub fn shell_quote(text: &OsStr) -> OsString
Expand description

What: Quote operating-system text as one word of a POSIX shell command. Why: Git runs a hook.<name>.command that holds a space through sh -c, so a path with spaces or quotes must stay one word; single quotes keep every byte literal, and an embedded single quote is closed, escaped and reopened.

In TS you’d write (pseudocode):

`'${text.replaceAll("'", "'\\''")}'`