From e3fd4d3f8176cd8539a985e2994f229cb3337340 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Thu, 3 Oct 2024 10:10:11 -0500 Subject: [PATCH] since windows allows slash or backslash, allow both instead of MAIN_SEPARATOR (#13996) # Description I mean't to do this small change the other day but forgot. We probably shouldn't be using MAIN_SEPARATOR because **\\*.rs is an illegal glob. So, update this to just use slash. # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/filesystem/glob.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/nu-command/src/filesystem/glob.rs b/crates/nu-command/src/filesystem/glob.rs index 219853f6cb..1f475efbac 100644 --- a/crates/nu-command/src/filesystem/glob.rs +++ b/crates/nu-command/src/filesystem/glob.rs @@ -169,12 +169,14 @@ impl Command for Glob { }); } + // below we have to check / instead of MAIN_SEPARATOR because glob uses / as separator + // using a glob like **\*.rs should fail because it's not a valid glob pattern let folder_depth = if let Some(depth) = depth { depth } else if glob_pattern.contains("**") { usize::MAX - } else if glob_pattern.contains(std::path::MAIN_SEPARATOR) { - glob_pattern.split(std::path::MAIN_SEPARATOR).count() + 1 + } else if glob_pattern.contains('/') { + glob_pattern.split('/').count() + 1 } else { 1 };