MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / shell_escape

Function shell_escape

crates/openshell-core/src/forward.rs:765–779  ·  view source on GitHub ↗

Shell-escape a value for use inside a `ProxyCommand` string.

(value: &str)

Source from the content-addressed store, hash-verified

763
764/// Shell-escape a value for use inside a `ProxyCommand` string.
765pub fn shell_escape(value: &str) -> String {
766 if value.is_empty() {
767 return "''".to_string();
768 }
769
770 let safe = value
771 .bytes()
772 .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'.' | b'/' | b'-' | b'_'));
773 if safe {
774 return value.to_string();
775 }
776
777 let escaped = value.replace('\'', "'\"'\"'");
778 format!("'{escaped}'")
779}
780
781/// Build the SSH `ProxyCommand` string used to tunnel to a sandbox.
782///

Callers 2

sandbox_exec_with_modeFunction · 0.50
render_ssh_configFunction · 0.50

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected