shlex

Types

An error that occurs when lexing a shell input

pub type LexError {
  UnclosedQuotation
  NoEscapedCharacter
}

Constructors

  • UnclosedQuotation

    A quote was opened without a matching closing quote

  • NoEscapedCharacter

Values

pub fn split(input: String) -> Result(List(String), LexError)

Split a shell input into a list of string tokens.

This aims to follow the POSIX standard defined by IEEE Std 1003.1-2024.

Examples

let assert Ok(tokens) = split("git commit -m 'hello world!'")
assert tokens == ["git", "commit", "-m", "hello worlds!"]
Search Document