Skip to main content

shell_quote

Function shell_quote 

Source
pub fn shell_quote(unquoted_string: impl AsRef<OsStr>) -> OsString
Expand description

Quotes a string so that the shell (/bin/sh) will interpret the quoted string to mean @unquoted_string.

If you pass a filename or other untrusted input to shell_parse_argv(), you should first quote it with this function. This is sufficient to ensure untrusted input cannot ‘break out’ of the quotes. Beware: this only works because shell_parse_argv() is not a real Unix shell. Quoting untrusted input is not an adequate security mechanism when using a real shell.

The return value must be freed with g_free().

The quoting style used is undefined (single or double quotes may be used).

§unquoted_string

a literal string

§Returns

quoted string