aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/comp
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/comp')
-rw-r--r--mingling_core/src/comp/shell_ctx.rs10
1 files changed, 8 insertions, 2 deletions
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<Vec<String>> 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()