Skip to content

Commit

Permalink
fix(builtins): fix read builtin ignoring tab chars (#371)
Browse files Browse the repository at this point in the history
Don't ignore whitespace chars, even if they're considered control characters.
  • Loading branch information
reubeno authored Feb 1, 2025
1 parent ee71122 commit d8a57de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion brush-core/src/builtins/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl ReadCommand {
}

// Ignore other control characters without including them in the input.
if ch.is_ascii_control() {
if ch.is_ascii_control() && !ch.is_ascii_whitespace() {
continue;
}

Expand Down
6 changes: 6 additions & 0 deletions brush-shell/tests/cases/builtins/read.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ cases:
while IFS= read line; do
echo "LINE: '$line'"
done <<<"${content}"
- name: "read text with tabs and custom IFS"
stdin: |
while IFS="" read myvar; do
echo "myvar1: |${myvar}|"
done < <(printf "a\tb\nc d\te\n")

0 comments on commit d8a57de

Please sign in to comment.