Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions crates/bashkit/src/builtins/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,34 @@ impl Builtin for Echo {
let mut interpret_escapes = false;
let mut args_iter = ctx.args.iter().peekable();

// Parse options
// Parse options - support combined flags like -en, -ne, -neE
while let Some(arg) = args_iter.peek() {
match arg.as_str() {
"-n" => {
add_newline = false;
args_iter.next();
}
"-e" => {
interpret_escapes = true;
args_iter.next();
let arg_str = arg.as_str();
if arg_str.starts_with('-') && arg_str.len() > 1 && !arg_str.starts_with("--") {
let mut is_valid_option = true;
// Check if all characters after '-' are valid options
for c in arg_str[1..].chars() {
if !matches!(c, 'n' | 'e' | 'E') {
is_valid_option = false;
break;
}
}
"-E" => {
interpret_escapes = false;
if is_valid_option {
// Process each flag character
for c in arg_str[1..].chars() {
match c {
'n' => add_newline = false,
'e' => interpret_escapes = true,
'E' => interpret_escapes = false,
_ => {}
}
}
args_iter.next();
} else {
break;
}
_ => break,
} else {
break;
}
}

Expand Down
10 changes: 4 additions & 6 deletions crates/bashkit/tests/spec_cases/bash/echo.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ world
### end

### echo_combined_en
### skip: combined flag handling differs
# Combined -en flags
echo -en "hello\nworld"
printf '\n'
Expand All @@ -91,7 +90,6 @@ world
### end

### echo_combined_ne
### skip: combined flag handling differs
# Combined -ne flags
echo -ne "a\tb"
printf '\n'
Expand All @@ -100,7 +98,7 @@ a b
### end

### echo_E_flag
### skip: -E flag (disable escapes) not implemented
# -E flag disables escape interpretation
echo -E "hello\nworld"
### expect
hello\nworld
Expand Down Expand Up @@ -165,15 +163,15 @@ echo "?"
### end

### echo_escape_hex
### skip: hex escapes in echo -e not implemented
# Hex escapes in echo -e
echo -e "\x48\x65\x6c\x6c\x6f"
### expect
Hello
### end

### echo_escape_octal
### skip: octal escapes in echo -e not implemented
echo -e "\110\145\154\154\157"
# Octal escapes in echo -e use \0nnn format
echo -e "\0110\0145\0154\0154\0157"
### expect
Hello
### end
12 changes: 6 additions & 6 deletions crates/bashkit/tests/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
//! - [ ] sort -f, -t, -k, -s, -c, -m, -h, -M, -o, -z - not implemented
//! - [ ] uniq -d, -u, -i, -f - not implemented
//!
//! ### echo.test.sh (9 skipped)
//! - [ ] echo_empty_* (2) - test format expects empty/newline mismatch
//! ### echo.test.sh (4 skipped)
//! - [x] echo_combined_en, echo_combined_ne - combined flag handling fixed
//! - [x] echo_E_flag - -E flag now works
//! - [x] echo_escape_hex, echo_escape_octal - hex/octal escapes work
//! - [ ] echo_empty, echo_no_newline - test format expects empty/newline mismatch
//! - [ ] echo_escape_r - carriage return handling differs
//! - [ ] echo_combined_en, echo_combined_ne - combined flag handling differs
//! - [ ] echo_E_flag - -E flag (disable escapes) not implemented
//! - [ ] echo_option_end - -- to end options not implemented
//! - [ ] echo_escape_hex, echo_escape_octal - hex/octal escapes not implemented
//! - [ ] echo_double_dash - -- to end options not implemented
//!
//! ### fileops.test.sh (5 skipped) - filesystem visibility
//! - [ ] mkdir_*, touch_*, mv_file - test conditionals not seeing fs changes
Expand Down
16 changes: 8 additions & 8 deletions specs/004-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ crates/bashkit/tests/

| Category | Test Cases | In CI | Pass | Skip |
|----------|------------|-------|------|------|
| Bash | 362 | Yes | 254 | 108 |
| Bash | 362 | Yes | 259 | 103 |
| AWK | 19 | Yes | 17 | 2 |
| Grep | 15 | Yes | 15 | 0 |
| Sed | 17 | Yes | 17 | 0 |
| JQ | 21 | Yes | 21 | 0 |
| **Total** | **434** | **434** | 324 | 110 |
| **Total** | **434** | **434** | 329 | 105 |

### Test File Format

Expand Down Expand Up @@ -152,20 +152,20 @@ The coverage workflow runs on every PR and push to main. Reports are uploaded
to Codecov and available as CI artifacts.

### Current Status
- All spec tests: 75% pass rate (324/434 running in CI, 110 skipped)
- All spec tests: 76% pass rate (329/434 running in CI, 105 skipped)
- Text processing tools: 97% pass rate (70/72 running, 2 AWK skipped)
- Core bash specs: 100% pass rate (254/254 running, 108 skipped)
- Core bash specs: 100% pass rate (259/259 running, 103 skipped)

## TODO: Testing Gaps

The following items need attention:

- [x] **Enable bash_spec_tests in CI** - Done! 325/435 tests running
- [x] **Add bash_comparison_tests to CI** - Done! 304 tests compared against real bash
- [x] **Enable bash_spec_tests in CI** - Done! 330/435 tests running
- [x] **Add bash_comparison_tests to CI** - Done! 309 tests compared against real bash
- [x] **Fix control-flow.test.sh** - Enabled! 31 tests now running
- [x] **Add coverage tooling** - cargo-tarpaulin + Codecov via `.github/workflows/coverage.yml`
- [ ] **Fix skipped spec tests** (110 total):
- Bash: 108 skipped (various implementation gaps)
- [ ] **Fix skipped spec tests** (105 total):
- Bash: 103 skipped (various implementation gaps)
- AWK: 2 skipped (blocked by multi-statement action parsing bug)
- [ ] **Fix bash_diff tests** (21 total):
- wc: 14 tests (output formatting differs)
Expand Down
Loading