From dad8035eefecb50ed591deab93333437e839dc9d Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 21 Dec 2022 20:57:20 -0500 Subject: [PATCH] Support shell expansion in src field (#1324) --- src/settings/configuration.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/settings/configuration.rs b/src/settings/configuration.rs index 0f86b2a534..aaeba6c1ec 100644 --- a/src/settings/configuration.rs +++ b/src/settings/configuration.rs @@ -2,12 +2,15 @@ //! command-line options. Structure mirrors the user-facing representation of //! the various parameters. +use std::borrow::Cow; +use std::env::VarError; use std::path::{Path, PathBuf}; use anyhow::{anyhow, Result}; use glob::{glob, GlobError, Paths, PatternError}; use regex::Regex; use shellexpand; +use shellexpand::LookupError; use crate::checks_gen::CheckCodePrefix; use crate::cli::{collect_per_file_ignores, Overrides}; @@ -274,9 +277,13 @@ impl Configuration { /// Given a list of source paths, which could include glob patterns, resolve the /// matching paths. pub fn resolve_src(src: &[String], project_root: &Path) -> Result> { - let globs = src + let expansions = src .iter() - .map(Path::new) + .map(shellexpand::full) + .collect::>, LookupError>>()?; + let globs = expansions + .iter() + .map(|path| Path::new(path.as_ref())) .map(|path| fs::normalize_path_to(path, project_root)) .map(|path| glob(&path.to_string_lossy())) .collect::, PatternError>>()?;