Pure POSIX shell-quoting helpers.
Two functions:
shell-quote — single-quote a string for safe embedding in a
sh -c command, escaping embedded single-quotes and quoting the
empty string as '' so it survives tokenization.join-as-cmd — join an argv into one shell-command string by
quoting each element with shell-quote.Re-quoting an already-quoted string nests correctly — each sh -c
peel removes exactly one quoting layer.
Pure POSIX shell-quoting helpers.
Two functions:
- `shell-quote` — single-quote a string for safe embedding in a
`sh -c` command, escaping embedded single-quotes and quoting the
empty string as `''` so it survives tokenization.
- `join-as-cmd` — join an argv into one shell-command string by
quoting each element with `shell-quote`.
Re-quoting an already-quoted string nests correctly — each `sh -c`
peel removes exactly one quoting layer.(join-as-cmd argv)Quote every element of argv with shell-quote and join with spaces
into a single command string suitable for sh -c.
Quote every element of `argv` with `shell-quote` and join with spaces into a single command string suitable for `sh -c`.
(shell-quote arg)POSIX single-quote arg for safe embedding in a sh -c command.
'' (otherwise it would collapse into adjacent
whitespace during sh tokenization)'…', with embedded '
rewritten as '\''POSIX single-quote `arg` for safe embedding in a `sh -c` command. - empty string → `''` (otherwise it would collapse into adjacent whitespace during sh tokenization) - string with shell metacharacters → `'…'`, with embedded `'` rewritten as `'\''` - otherwise → returned unchanged.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |