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
4 changes: 2 additions & 2 deletions crates/bashkit/src/builtins/awk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ fn normalize_awk_newlines(input: &str) -> String {
i += 1;
}
}
'/' if brace_depth > 0 => {
// Potential regex literal — pass through unchanged
'/' => {
// Regex literal — pass through unchanged (both pattern and expression context)
result.push('/');
i += 1;
while i < chars.len() && chars[i] != '/' {
Expand Down
21 changes: 21 additions & 0 deletions crates/bashkit/tests/spec_cases/awk/awk.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -703,3 +703,24 @@ awk 'BEGIN{print "caf\u00E9"}'
### expect
café
### end

### awk_regex_hash_pattern
# Issue #835: # inside regex pattern should not be treated as comment
echo '#test' | awk '/#/ { print "matched" }'
### expect
matched
### end

### awk_regex_hash_caret
# Issue #835: /^#/ pattern
printf '# heading\nnormal\n' | awk '/^#/ { print "comment:", $0 }'
### expect
comment: # heading
### end

### awk_regex_hash_no_match
# Regex without # still works
echo 'abc' | awk '/abc/ { print "yes" }'
### expect
yes
### end
Loading