shlex

package
v0.3.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shlex splits and quotes command lines the way the Rust shlex crate (1.3) does, byte for byte: the launcher's hooks, templates, and `-format q` output have to agree with what the Rust shell produced.

Splitting is POSIX-shell word splitting without expansion: single and double quotes, backslash escapes, and `#` comments at a word start. An unbalanced quote or a trailing backslash is an error, never half a command.

Index

Constants

This section is empty.

Variables

View Source
var ErrNul = errors.New("cannot shell-quote string containing nul byte")

ErrNul reports a string that cannot be quoted because it holds a NUL byte (shlex::QuoteError::Nul).

Functions

func MustQuote

func MustQuote(in string) string

MustQuote is Quote with the input returned unchanged when it cannot be quoted - the `.unwrap_or_else(|_| text.clone())` the Rust callers use.

func Quote

func Quote(in string) (string, error)

Quote returns in quoted for a POSIX shell (shlex::try_quote): bare when every byte is safe, otherwise in single- or double-quoted chunks. A NUL byte cannot be quoted and is ErrNul.

func Split

func Split(in string) ([]string, bool)

Split splits in into words, or reports false when it does not parse (an unbalanced quote, a dangling backslash).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL