Skip to main content

Module shell_words

Module shell_words 

Source
Expand description

POSIX shell tokenization for crate::constraints::Shlex.

Words end at unquoted spaces, tabs, or operators. # is an ordinary word character, never a comment, so an operator after # is still rejected even when a shell would not treat # as a comment. A comma, bracket, or other non-operator character stays inside the word, so ./ls,evil is one command name. Quoted and backslash-escaped operator characters are literal arguments.

check is the only decision. Callers that explain a denial use its reason instead of a second parser.

Structs§

ShlexCheck
The core’s decision for one command. reason is the explanation.
Token
A token from tokenize. operator is set only for an unquoted operator.

Enums§

ShellError
Why tokenize refused the command.

Functions§

check
Decide whether command is one allowlisted binary and literal arguments.
command_allowed
Whether check allows the command.
tokenize
Split input the way a POSIX shell splits words, without expansion.