Crates.io | shellexpand |
lib.rs | shellexpand |
version | 3.1.0 |
source | src |
created_at | 2016-03-13 17:26:33.513425 |
updated_at | 2023-03-24 11:27:36.187411 |
description | Shell-like expansions in strings |
homepage | |
repository | https://gitlab.com/ijackson/rust-shellexpand |
max_upload_size | |
id | 4444 |
size | 89,459 |
shellexpand is a single dependency library which allows one to perform shell-like expansions in strings,
that is, to expand variables like $A
or ${B}
into their values inside some context and to expand
~
in the beginning of a string into the home directory (again, inside some context).
This crate provides generic functions which accept arbitrary contexts as well as default, system-based
functions which perform expansions using the system-wide context (represented by functions from std::env
module and dirs crate).
expanduser
:
Tilde substitution only.
Supports ~user
which this crate currently does not
(although we hope to).envsubst
:
Does not do offer tildeexpansion.
Only supports certain concrete types
(eg HashMap
for variable map).expand_str
:
Uses %..%
syntax.
Does not offer tilde expansion.
Variable lookups can only be infallible.tilde_expand
:
Only does tilde expansion, on bytes ([u8]
).Just add a dependency in your Cargo.toml
:
[dependencies]
shellexpand = "3.0"
See the crate documentation (a link is present in the beginning of this readme) for more information and examples.
Functional features:
tilde
(on by default): support for tilde expansion (home directory).path
(in full
): support for operations on Path
s. (MSRV: 1.51)Metafeatures:
full
: all reasonable (non-experimental, non-hazardous) functionality.
(Currently equivalent to full-msrv-1.51
.)base-0
(on by default): basic functionality.
You must enable this feature.full-msrv-1.51
: all reasonable functionality compatible with Rust 1.51.
(currently: base-0
, tilde
, paths
).full-msrv-1.31
: all reasonable functionality compatible with Rust 1.31.
(currently: base-0
, tilde
).At the time of writing there is no experimental or hazardous functionality;
if we introduce any it will be feature gated and not enabled by default nor part of full*
.
Requiring base-0
allows us to split existing functionality into a new optional feature,
without a semver break.
We will try to avoid MSRV increases for existing functionality;
increasing the MSRV for full
will be minor version bump.
Added:
full-msrv-1.31
and full-msrv-1.51
Fixed:
paths
feature.paths
feature) with MSRV (1.31)Improved:
dirs
5. (Allow use of dirs 4 too, since it's fine.)Cargo.lock.exaple
Breaking changes:
tilde_with_context
and full_with_context
now expect home directories as str
, not Path
.
If you want to deal in Path, use the path
feature and module.base-0
feature is equivalent to the features available in shellexpand 2.x.Significant changes:
path
module, and corresponding cargo feature.Minor changes:
shellexpand
on crates.io.cargo fix
.shellexpand-fork
on crates.io.dirs-next
instead of the obsolete dirs
as the underlying dependency used to resolve the home directory${ANSWER:-42}
)dyn
for trait objects to fix deprecation warningsource()
instead of cause()
in the Error
implementation, and
therefore added a 'static
bound for the generic error parameter E
dirs
dependency to 2.0.std::env::home_dir
to the dirs::home_dir functionhome_dir
argument type for tilde expansion functions to FnOnce
instead FnMut
LookupError::name
field name to var_name
This program is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.