From c01c3a53a5e117c60df846de7d2c1bdc43627a0b Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 3 Aug 2026 01:41:04 +0800 Subject: fix(shell-ctx): distinguish missing -F from empty flag Previously, an absent -F and a present -F without a value both mapped to "unknown". Now, a -F with no value maps to an empty shell flag, while a missing -F remains "unknown". --- mingling_core/src/comp/shell_ctx.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'mingling_core/src/comp') diff --git a/mingling_core/src/comp/shell_ctx.rs b/mingling_core/src/comp/shell_ctx.rs index 8efbc9d..734b5d2 100644 --- a/mingling_core/src/comp/shell_ctx.rs +++ b/mingling_core/src/comp/shell_ctx.rs @@ -50,8 +50,14 @@ impl TryFrom> for ShellContext { let word_index = special_argument!(args, "-i") .and_then(|s| s.parse().ok()) .unwrap_or_default(); - let shell_flag = special_argument!(args, "-F") - .map_or(ShellFlag::Other("unknown".to_string()), ShellFlag::from); + // Distinguish "-F absent" (unknown shell) from "-F present without a value" (empty shell) + let has_shell_flag = args.iter().any(|arg| arg == "-F"); + let shell_flag = if has_shell_flag { + special_argument!(args, "-F") + .map_or_else(|| ShellFlag::Other(String::new()), ShellFlag::from) + } else { + ShellFlag::Other("unknown".to_string()) + }; let all_words = command_line .split_whitespace() -- cgit