Added regex to [[ ]] tests
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::collections::{HashSet, VecDeque};
|
||||
|
||||
|
||||
use crate::{builtin::{alias::{alias, unalias}, cd::cd, echo::echo, export::export, flowctl::flowctl, jobctl::{continue_job, jobs, JobBehavior}, pwd::pwd, shift::shift, shopt::shopt, source::source, zoltraak::zoltraak}, expand::expand_aliases, jobs::{dispatch_job, ChildProc, JobBldr, JobStack}, libsh::{error::{ShErr, ShErrKind, ShResult, ShResultExt}, utils::RedirVecUtils}, prelude::*, procio::{IoFrame, IoMode, IoStack}, state::{self, get_snapshots, read_logic, restore_snapshot, write_logic, write_meta, write_vars, ShFunc, VarTab, LOGIC_TABLE}};
|
||||
use crate::{builtin::{alias::{alias, unalias}, cd::cd, echo::echo, export::export, flowctl::flowctl, jobctl::{continue_job, jobs, JobBehavior}, pwd::pwd, shift::shift, shopt::shopt, source::source, test::double_bracket_test, zoltraak::zoltraak}, expand::expand_aliases, jobs::{dispatch_job, ChildProc, JobBldr, JobStack}, libsh::{error::{ShErr, ShErrKind, ShResult, ShResultExt}, utils::RedirVecUtils}, prelude::*, procio::{IoFrame, IoMode, IoStack}, state::{self, get_snapshots, read_logic, restore_snapshot, write_logic, write_meta, write_vars, ShFunc, VarTab, LOGIC_TABLE}};
|
||||
|
||||
use super::{lex::{Span, Tk, TkFlags, KEYWORDS}, AssignKind, CaseNode, CondNode, ConjunctNode, ConjunctOp, LoopKind, NdFlags, NdRule, Node, ParsedSrc, Redir, RedirType};
|
||||
|
||||
@@ -86,6 +86,7 @@ impl Dispatcher {
|
||||
NdRule::BraceGrp {..} => self.exec_brc_grp(node)?,
|
||||
NdRule::FuncDef {..} => self.exec_func_def(node)?,
|
||||
NdRule::Command {..} => self.dispatch_cmd(node)?,
|
||||
NdRule::Test {..} => self.exec_test(node)?,
|
||||
_ => unreachable!()
|
||||
}
|
||||
Ok(())
|
||||
@@ -123,6 +124,14 @@ impl Dispatcher {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub fn exec_test(&mut self, node: Node) -> ShResult<()> {
|
||||
let test_result = double_bracket_test(node)?;
|
||||
match test_result {
|
||||
true => state::set_status(0),
|
||||
false => state::set_status(1),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub fn exec_func_def(&mut self, func_def: Node) -> ShResult<()> {
|
||||
let blame = func_def.get_span();
|
||||
let NdRule::FuncDef { name, body } = func_def.class else {
|
||||
@@ -159,7 +168,7 @@ impl Dispatcher {
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
self.set_assignments(assignments, AssignBehavior::Export);
|
||||
self.set_assignments(assignments, AssignBehavior::Export)?;
|
||||
self.io_stack.append_to_frame(subsh.redirs);
|
||||
let mut argv = prepare_argv(argv)?;
|
||||
|
||||
@@ -181,7 +190,7 @@ impl Dispatcher {
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
self.set_assignments(assignments, AssignBehavior::Export);
|
||||
self.set_assignments(assignments, AssignBehavior::Export)?;
|
||||
|
||||
self.io_stack.append_to_frame(func.redirs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user