pub fn shell_quote(value: &str) -> StringExpand description
value as a single POSIX shell word.
Two places need this and they must not answer it differently: the hook
command a consumer renders into HOOKS_MANIFEST_TEMPLATE is executed by
a shell, and the recovery commands manager::PluginManager::manual_commands
prints are copied into one. A home directory containing a space is
ordinary, and either use getting it wrong silently changes the arguments —
the executed hook runs against the wrong path, the pasted command registers
the wrong directory.
Quoting is applied only when the value needs it, so ordinary paths and
plugin specs print bare. The safe set is a deliberately short allowlist —
ASCII alphanumerics plus ._-/@:+,= — every member of which a POSIX shell
leaves alone in a non-leading word. Everything else, including the empty
string, is wrapped in single quotes, which suppress every expansion the
shell performs; the only character then needing care is the closing quote
itself, spliced out, escaped, and spliced back in.