shlex

Package VersionHex Docs

Split shell commands into words following POSIX specification.

gleam add shlex@1
import shlex
pub fn main() -> Nil {
let assert Ok(tokens) = shlex.split("git commit -m 'hello world!'")
// ["git", "commit", "-m", "hello worlds!"]
}

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

Development

gleam test # Run the tests

Comparison with other shell lexers

The tokenizer follows the implementation of rust-shlex, which is a simplified, POSIX-only version of Python shlex.