Add ! negation support, fix POSIX exit statuses, and improve vi emulation with comprehensive tests

This commit is contained in:
2026-03-07 21:57:04 -05:00
parent 490ce4571d
commit 07d7015dd4
16 changed files with 1240 additions and 211 deletions

View File

@@ -17,9 +17,9 @@ use crate::{
},
};
pub const KEYWORDS: [&str; 16] = [
pub const KEYWORDS: [&str; 17] = [
"if", "then", "elif", "else", "fi", "while", "until", "select", "for", "in", "do", "done",
"case", "esac", "[[", "]]",
"case", "esac", "[[", "]]", "!"
];
pub const OPENERS: [&str; 6] = ["if", "while", "until", "for", "select", "case"];
@@ -166,6 +166,7 @@ pub enum TkRule {
ErrPipe,
And,
Or,
Bang,
Bg,
Sep,
Redir,
@@ -882,6 +883,14 @@ impl Iterator for LexStream {
return self.next();
}
}
'!' if self.next_is_cmd() => {
self.cursor += 1;
let tk_type = TkRule::Bang;
let mut tk = self.get_token((self.cursor - 1)..self.cursor, tk_type);
tk.flags |= TkFlags::KEYWORD;
tk
}
'|' => {
let ch_idx = self.cursor;
self.cursor += 1;