use crate::parse::Token;
pub(crate) const SHELL_TEXT: &[char] = &['`', '$', '"', '\\', ';', '|', '&', '(', ')', '<', '>', '\n', '\r'];
pub(crate) fn holds_shell_text(word: &str) -> bool {
word.contains(SHELL_TEXT)
}
pub(crate) fn man_evaluates_a_word(tokens: &[Token]) -> bool {
tokens.iter().skip(1).any(|token| holds_shell_text(token.as_str()))
}
pub(crate) fn splits_a_flag(tokens: &[Token]) -> bool {
const SPLIT: &[char] = &[' ', '\t', '\n', '*', '?', '['];
tokens
.iter()
.skip(1)
.map(Token::as_str)
.take_while(|word| word.starts_with('-'))
.any(|word| word.contains(SPLIT))
}
pub(crate) fn hands_flags_to_another_pager(tokens: &[Token]) -> bool {
crate::cst::pager_may_be_set() && !tokens.get(1).map(Token::as_str).is_some_and(|word| word == "--" || is_plain_file_name(word))
}
fn is_plain_file_name(word: &str) -> bool {
!word.is_empty() && !word.starts_with('-') && !word.contains(['{', '}', '*', '?', '[', '$', '`']) && !word.contains("__SAFE_CHAINS_")
}
#[cfg(test)]
#[path = "shell_text_tests.rs"]
mod tests;