shellexpand_utils/
lib.rs

1pub mod canonicalize;
2mod error;
3pub mod expand;
4
5use std::path::{Path, PathBuf};
6
7#[doc(inline)]
8pub use crate::error::{Error, Result};
9
10pub fn try_shellexpand_path(path: impl AsRef<Path>) -> Result<PathBuf> {
11    let path = expand::try_path(path)?;
12    let path = canonicalize::try_path(path)?;
13    Ok(path)
14}
15
16pub fn shellexpand_path(path: impl AsRef<Path>) -> PathBuf {
17    canonicalize::path(expand::path(path))
18}
19
20pub fn try_shellexpand_str(str: impl AsRef<str>) -> Result<String> {
21    let str = expand::try_str(str)?;
22    Ok(str)
23}
24
25pub fn shellexpand_str(str: impl AsRef<str>) -> String {
26    expand::str(str)
27}