From a1028c629daf50a48024ad003202ee0f7c0cacc3 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Mon, 3 Nov 2025 23:58:48 -0500 Subject: [PATCH] fix(eficore/env): improve quirk handling for dell systems --- crates/eficore/src/env.rs | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/crates/eficore/src/env.rs b/crates/eficore/src/env.rs index c4d1243..ccfb7dc 100644 --- a/crates/eficore/src/env.rs +++ b/crates/eficore/src/env.rs @@ -45,25 +45,17 @@ pub fn args() -> Result> { // Correct firmware that may add invalid arguments at the start. // Witnessed this on a Dell Precision 5690 when direct booting. - loop { - // Grab the first argument or break. - let Some(arg) = args.first() else { - break; - }; - - // Check if the argument is a valid character. - // If it is not, remove it and continue. - let Some(first_character) = arg.chars().next() else { - break; - }; - - // If the character is not a printable character or a backtick, remove it and continue. - if first_character < 0x1f as char || first_character == '`' { - args.remove(0); - continue; - } - break; - } + args = args + .into_iter() + .skip_while(|arg| { + arg.chars() + .next() + // Filter out unprintable characters and backticks. + // Both of which have been observed in the wild. + .map(|c| c < 0x1f as char || c == '`') + .unwrap_or(false) + }) + .collect(); // If there is a first argument, check if it is not an option. // If it is not, we will assume it is the path to the executable and remove it.