use crate::compsys::ported::shared::dispatch_action_command;
use crate::ported::params::{getaparam, getsparam};
use crate::ported::zle::complete::bin_compset;
use crate::ported::zsh_h::{options, MAX_OPS};
fn make_ops() -> options {
options {
ind: [0u8; MAX_OPS],
args: Vec::new(),
argscount: 0,
argsalloc: 0,
}
}
pub fn _equal() -> i32 {
let _fn_scope = crate::compsys::ported::shared::FnScope::enter("_equal");
let prefix = getsparam("PREFIX").unwrap_or_default();
if dispatch_action_command("_have_glob_qual", &[prefix], 5) == 0 {
let match_arr = getaparam("match").unwrap_or_default();
let match1_len = match_arr.first().map(|s| s.len()).unwrap_or(0);
let _ = bin_compset(
"compset",
&["-p".to_string(), match1_len.to_string()],
&make_ops(),
0,
);
let _ = bin_compset(
"compset",
&["-S".to_string(), "[^\\)\\|\\~]#(|\\))".to_string()],
&make_ops(),
0,
);
dispatch_action_command("_globquals", &[], 8)
} else {
dispatch_action_command("_path_commands", &[], 10)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn unresolvable_command_word_reports_not_found() {
let _g = crate::test_util::global_state_lock();
assert_eq!(_equal(), 127);
}
}