Commit ef0c02d
fix(interpreter): count unicode chars in ${#x} and add printf \u/\U escapes (#378)
## Summary
- Fix `${#x}` to count Unicode characters instead of bytes: `x=café;
echo ${#x}` now correctly returns `4` instead of `5`
- Add `\uHHHH` (4-digit) and `\UHHHHHHHH` (8-digit) Unicode escape
handling to the printf builtin, both in format strings and `%b` argument
expansion
- Remove 3 `### skip:` markers from `unicode.test.sh` and replace with
`### bash_diff:` markers (system bash behavior differs based on locale)
## Test plan
- [x] `cargo fmt --check` clean
- [x] `cargo clippy --all-targets --all-features -- -D warnings` clean
- [x] All 1015 unit tests pass
- [x] Bash spec tests: 1184 passed, 0 failed (100% pass rate)
- [x] Bash comparison tests: 1081/1081 match real bash (100%)
- [x] New printf unicode unit tests: `test_unicode_escape_u`,
`test_unicode_escape_big_u`, `test_unicode_escape_ascii`,
`test_unicode_escape_in_expand`
Closes #362
Co-authored-by: Claude <noreply@anthropic.com>1 parent d3d162a commit ef0c02d
File tree
4 files changed
+87
-5
lines changed- crates/bashkit
- src
- builtins
- interpreter
- tests
- spec_cases/bash
4 files changed
+87
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
235 | 247 | | |
236 | 248 | | |
237 | 249 | | |
| |||
451 | 463 | | |
452 | 464 | | |
453 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
454 | 478 | | |
455 | 479 | | |
456 | 480 | | |
| |||
467 | 491 | | |
468 | 492 | | |
469 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
470 | 518 | | |
471 | 519 | | |
472 | 520 | | |
| |||
533 | 581 | | |
534 | 582 | | |
535 | 583 | | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
536 | 618 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5041 | 5041 | | |
5042 | 5042 | | |
5043 | 5043 | | |
5044 | | - | |
| 5044 | + | |
5045 | 5045 | | |
5046 | 5046 | | |
5047 | 5047 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
0 commit comments