MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / shell_quote

Function shell_quote

atomic-cli/src/commands/update.rs:335–337  ·  view source on GitHub ↗

POSIX single-quote escape for arbitrary strings. Wraps the value in single quotes and escapes any embedded single quote as `'\''` (end quote, escaped quote, start quote). The result is safe to paste into any POSIX shell without parameter expansion, command substitution, or backslash interpretation. We use this for paths that come from the install manifest, which is user-writable — a path contain

(s: &str)

Source from the content-addressed store, hash-verified

333/// be able to break the copy-pasteable upgrade hint or smuggle
334/// expansion into the user's shell.
335fn shell_quote(s: &str) -> String {
336 format!("'{}'", s.replace('\'', "'\\''"))
337}
338
339/// Render an `ATOMIC_INSTALL=...` value suitable for embedding in a shell
340/// snippet. When the directory equals `$HOME/.local/bin` literally we

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected