Skip to content

Commit

Permalink
Enable to scan -eq, -ne, ...
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Sep 22, 2024
1 parent c2ab60f commit 090f1c4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
13 changes: 13 additions & 0 deletions src/elements/expr/conditional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ impl ConditionalExpr {
return Ok(());
}

if op == "-eq" || op == "-ne" || op == "-lt" || op == "-le" || op == "-gt" || op == "-ge" {
let ans = match op {
"==" | "=" => left == right,
"!=" => left != right,
">" => left > right,
"<" => left < right,
_ => false,
};

stack.push( Elem::Ans(ans) );
return Ok(());
}

let result = file_check::metadata_comp(&left, &right, op);
stack.push( Elem::Ans(result) );
Ok(())
Expand Down
3 changes: 2 additions & 1 deletion src/feeder/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ impl Feeder {

pub fn scanner_test_compare_op(&mut self, core: &mut ShellCore) -> usize {
self.backslash_check_and_feed(vec!["-", "-e", "-n", "-o", "=", "!"], core);
self.scanner_one_of(&["-ef", "-nt", "-ot", "==", "=", "!=", "<", ">"])
self.scanner_one_of(&["-ef", "-nt", "-ot", "==", "=", "!=", "<", ">",
"-eq", "-ne", "-lt", "-le", "-gt", "-ge"])
}
}
4 changes: 0 additions & 4 deletions test/error
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
../../../test/test_compound.bash
../../../test/test_compound.bash
../../../test/test_compound.bash
../../../test/test_compound.bash
10 changes: 0 additions & 10 deletions test/ok
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,3 @@
./test_compound.bash
./test_others.bash
./test_job.bash
../../../test/test_compound.bash
../../../test/test_compound.bash
../../../test/test_compound.bash
../../../test/test_compound.bash
../../../test/test_compound.bash
../../../test/test_compound.bash
../../../test/test_compound.bash
../../../test/test_compound.bash
../../../test/test_compound.bash
../../../test/test_compound.bash

0 comments on commit 090f1c4

Please sign in to comment.