diff --git a/crates/nu-command/src/filesystem/glob.rs b/crates/nu-command/src/filesystem/glob.rs index 2976c765a2..faba600c94 100644 --- a/crates/nu-command/src/filesystem/glob.rs +++ b/crates/nu-command/src/filesystem/glob.rs @@ -150,32 +150,7 @@ impl Command for Glob { let glob_pattern = match glob_pattern_input { - Value::String { val, .. } => { - if val.is_empty() { - return Err(ShellError::GenericError { - error: "glob pattern must not be empty".into(), - msg: "glob pattern is empty".into(), - span: Some(glob_span), - help: Some("add characters to the glob pattern".into()), - inner: vec![], - }); - } else { - val - } - } - Value::Glob { val, .. } => { - if val.is_empty() { - return Err(ShellError::GenericError { - error: "glob pattern must not be empty".into(), - msg: "glob pattern is empty".into(), - span: Some(glob_span), - help: Some("add characters to the glob pattern".into()), - inner: vec![], - }); - } else { - val - } - } + Value::String { val, .. } | Value::Glob { val, .. } => val, _ => return Err(ShellError::IncorrectValue { msg: "Incorrect glob pattern supplied to glob. Please use string or glob only." .to_string(), @@ -184,6 +159,16 @@ impl Command for Glob { }), }; + if glob_pattern.is_empty() { + return Err(ShellError::GenericError { + error: "glob pattern must not be empty".into(), + msg: "glob pattern is empty".into(), + span: Some(glob_span), + help: Some("add characters to the glob pattern".into()), + inner: vec![], + }); + } + let folder_depth = if let Some(depth) = depth { depth } else {