Commit 183eaa2
fix(builtins): count newlines for wc -l instead of logical lines (#481)
## Summary
- Fixed `wc -l` to count `\n` characters instead of using Rust's
`.lines().count()`, matching real bash behavior
- `printf "a\nb\nc"` now correctly returns 2 (two newlines) instead of 3
(three logical lines)
- Added tests for wc -l in pipe contexts
Closes #401
## Test plan
- [x] test_wc_l_in_pipe
- [x] test_wc_l_in_pipe_subst
- [x] test_wc_l_counts_newlines
- [x] All existing wc tests pass
Co-authored-by: Claude <noreply@anthropic.com>1 parent fc51ce0 commit 183eaa2
2 files changed
+43
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
| 189 | + | |
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9686 | 9686 | | |
9687 | 9687 | | |
9688 | 9688 | | |
| 9689 | + | |
| 9690 | + | |
| 9691 | + | |
| 9692 | + | |
| 9693 | + | |
| 9694 | + | |
| 9695 | + | |
| 9696 | + | |
| 9697 | + | |
| 9698 | + | |
| 9699 | + | |
| 9700 | + | |
| 9701 | + | |
| 9702 | + | |
| 9703 | + | |
| 9704 | + | |
| 9705 | + | |
| 9706 | + | |
| 9707 | + | |
| 9708 | + | |
| 9709 | + | |
| 9710 | + | |
| 9711 | + | |
| 9712 | + | |
| 9713 | + | |
| 9714 | + | |
| 9715 | + | |
| 9716 | + | |
| 9717 | + | |
| 9718 | + | |
| 9719 | + | |
| 9720 | + | |
| 9721 | + | |
| 9722 | + | |
| 9723 | + | |
| 9724 | + | |
| 9725 | + | |
| 9726 | + | |
| 9727 | + | |
| 9728 | + | |
| 9729 | + | |
9689 | 9730 | | |
0 commit comments