element.version === currentVersion)) { versionNodes.unshift({ version: currentVersion, url: "#" }); } document.querySelector("#project-version").innerHTML = versionNodes.reduce( (acc, element) => { const status = currentVersion === element.version ? "selected disabled" : ""; return ` ${acc} `; }, `
shlex · v1.1.1

shlex

Package Version Hex Docs

Split shell commands into words or join words into escaped commands. It’s Python shlex*, for Gleam.

gleam add shlex@1
import shlex

pub fn main() {
  shlex.split("git commit -m 'hello world!'") |> echo
  // Ok(["git", "commit", "-m", "hello world!"])

  shlex.join(["git", "commit", "-m", "hello world!"]) |> echo
  // "git commit -m 'hello world!'"

  shlex.quote(";cat /etc/passwd") |> echo
  // "';cat /etc/passwd'"
}

Further documentation can be found at https://hexdocs.pm/shlex.

Limitations

Like the Python shlex library, quoting only ensures safety in POSIX-compliant, non-interactive shells. Quoted outputs could still be vulnerable to shell injection if you paste them into a shell with interactive features like history expansion and quick substitution.

Development

gleam test  # Run the tests

*shlex.split matches Python’s posix=True mode, so it’s more like rust-shlex.

Search Document