mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-24 05:41:14 -03:00
wgetopt: fix long option match to always match prefix
This commit is contained in:
committed by
Johannes Altmanninger
parent
1adfce18ee
commit
844174367b
@@ -450,19 +450,22 @@ fn _find_matching_long_opt(
|
||||
|
||||
// Test all long options for either exact match or abbreviated matches.
|
||||
for (option_index, p) in self.longopts.iter().enumerate() {
|
||||
// Check if current option is prefix of long opt
|
||||
if p.name.starts_with(&self.nextchar[..nameend]) {
|
||||
// Exact match found.
|
||||
pfound = Some(*p);
|
||||
*indfound = option_index;
|
||||
*exact = true;
|
||||
break;
|
||||
} else if pfound.is_none() {
|
||||
// First nonexact match found.
|
||||
pfound = Some(*p);
|
||||
*indfound = option_index;
|
||||
} else {
|
||||
// Second or later nonexact match found.
|
||||
*ambig = true;
|
||||
if nameend == p.name.len() {
|
||||
// The current option is exact match of this long option
|
||||
pfound = Some(*p);
|
||||
*indfound = option_index;
|
||||
*exact = true;
|
||||
break;
|
||||
} else if pfound.is_none() {
|
||||
// current option is first prefix match but not exact match
|
||||
pfound = Some(*p);
|
||||
*indfound = option_index;
|
||||
} else {
|
||||
// current option is second or later prefix match but not exact match
|
||||
*ambig = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pfound;
|
||||
|
||||
Reference in New Issue
Block a user