use crate::ported::exec_hooks::dispatch_function_call;
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 prefix = getsparam("PREFIX").unwrap_or_default();
if dispatch_function_call("_have_glob_qual", &[prefix]).unwrap_or(1) == 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_function_call("_globquals", &[]).unwrap_or(1)
} else {
dispatch_function_call("_path_commands", &[]).unwrap_or(1)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn returns_one_without_executor() {
let _g = crate::test_util::global_state_lock();
assert_eq!(_equal(), 1);
}
}