mirror of
https://github.com/nushell/nushell.git
synced 2025-04-15 16:58:19 +02:00
fix du
--exclude
globbing bug (#12093)
# Description This PR fixes a globbing bug in the `du` command. The problem was that `--exclude` needed to be a `NuGlob` instead of a `String`. A variety of ways were tried to fix this, including spread operators and `into glob` but none of them worked. Here's the [Discord Conversation](https://discord.com/channels/601130461678272522/1214950311207243796/1214950311207243796) that documents the attempts. ### Before ```nushell ❯ du $env.PWD -x crates/** Error: nu:🐚:cant_convert × Can't convert to string. ╭─[entry #1:1:16] 1 │ du $env.PWD -x crates/** · ────┬──── · ╰── can't convert glob to string ╰──── ``` ### After ```nushell ❯ du $env.PWD -x crates/** ╭─#─┬────path────┬apparent─┬physical─┬───directories───┬files╮ │ 0 │ D:\nushell │ 55.6 MB │ 55.6 MB │ [table 17 rows] │ │ ╰───┴────────────┴─────────┴─────────┴─────────────────┴─────╯ ```
This commit is contained in:
parent
fe2761c7a6
commit
2ee3538de4
@ -18,7 +18,7 @@ pub struct DuArgs {
|
|||||||
path: Option<Spanned<NuGlob>>,
|
path: Option<Spanned<NuGlob>>,
|
||||||
all: bool,
|
all: bool,
|
||||||
deref: bool,
|
deref: bool,
|
||||||
exclude: Option<Spanned<String>>,
|
exclude: Option<Spanned<NuGlob>>,
|
||||||
#[serde(rename = "max-depth")]
|
#[serde(rename = "max-depth")]
|
||||||
max_depth: Option<Spanned<i64>>,
|
max_depth: Option<Spanned<i64>>,
|
||||||
#[serde(rename = "min-size")]
|
#[serde(rename = "min-size")]
|
||||||
@ -110,7 +110,7 @@ impl Command for Du {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let exclude = args.exclude.map_or(Ok(None), move |x| {
|
let exclude = args.exclude.map_or(Ok(None), move |x| {
|
||||||
Pattern::new(&x.item)
|
Pattern::new(x.item.as_ref())
|
||||||
.map(Some)
|
.map(Some)
|
||||||
.map_err(|e| ShellError::InvalidGlobPattern {
|
.map_err(|e| ShellError::InvalidGlobPattern {
|
||||||
msg: e.msg.into(),
|
msg: e.msg.into(),
|
||||||
|
Loading…
Reference in New Issue
Block a user