Skip to main content

Crate shvar

Crate shvar 

Source
Expand description

§shvar

shvar is the SHell VARiable expansion library.

§Status

Maintenance track. The library is considered stable and will be put into maintenance mode if unchanged for one year.

§Scope

This library provides the quote, split, expand, and rcvar functions.

§Warts

  • A string with '{' and '}' characters outside the variable declarations won’t parse right now.

§Breaking Changes

  • split("") now returns [] instead of [""]. Empty or whitespace-only input yields an empty vector.

§Documentation

The latest documentation is always available at docs.rs.

Structs§

EnvironmentProvider
A VariableProvider that reads variable values from the environment.
ExpandOptions
Configuration for which variable syntax forms are accepted during expansion.
PrefixingVariableProvider
A VariableProvider that prepends a prefix before lookup.

Enums§

Error
An error occurred during expansion or quoting operations.

Traits§

VariableProvider
A VariableProvider provides a way to lookup the value of a variable.
VariableWitness
A VariableWitness collects the identifiers of variables in use in a string.

Functions§

awkward_quote_string
Awkwardly quote the string.
double_quote_string
Put the string in double quotes, escaping ‘$’, ‘`’, ‘“’, ‘\’, and ‘\n’.
expand
Expand the input to a shell-quoted string suitable for passing to split.
expand_recursive
Recursively expand variables until no more expansions are possible.
expand_recursive_with_options
Recursively expand variables with custom options until no more expansions are possible.
expand_with_options
Expand the input with custom options to a shell-quoted string suitable for passing to split.
quote
Quote the pieces in such a way that splitting the quoted string will return the original pieces.
quote_string
Quote the string using double quotes, single quotes, or awkward quotes.
rcvar
Return a vector of the variables in use by this script.
rcvar_with_options
Return a vector of the variables in use by this script with custom options.
single_quote_string
Single quote the provided string, if it contains no single-quote characters.
split
Split the string in a way that respects quoting rules.
split_once
Parse a single shell-quoted argument from the input.