summaryrefslogtreecommitdiff
path: root/internal/io/fs
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-20 09:34:26 +0300
committerPaul Buetow <paul@buetow.org>2025-06-20 09:34:26 +0300
commitecc66fcf9241c429cf2378f09793ecef3a00b098 (patch)
tree4e671982bec11a6d12a1374b56bae2b89f0f4287 /internal/io/fs
parentc24e18b68b29384d2f63d44bfcbc9c02423edf78 (diff)
Fix line ending issue in dcat and add integration tests
- Fixed missing line endings in dcat output when not using --plain mode - Scanner.Bytes() strips newlines, so added logic to restore them - Only CatProcessor needs newlines added (GrepProcessor already adds them) - Added comprehensive integration tests for both dcat and dgrep line endings - Tests cover: basic usage, plain mode, multiple files, empty files, CRLF handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal/io/fs')
-rw-r--r--internal/io/fs/directprocessor.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/io/fs/directprocessor.go b/internal/io/fs/directprocessor.go
index dd259b6..e02d4c2 100644
--- a/internal/io/fs/directprocessor.go
+++ b/internal/io/fs/directprocessor.go
@@ -114,9 +114,19 @@ func (dp *DirectProcessor) ProcessReader(ctx context.Context, reader io.Reader,
return err
}
} else {
+ // Regular write path (e.g., stdout in serverless mode)
if _, err := dp.output.Write(result); err != nil {
return err
}
+
+ // Only add newline if the processor doesn't already handle it
+ // CatProcessor doesn't add newlines, but GrepProcessor does
+ if _, isCat := dp.processor.(*CatProcessor); isCat {
+ // Scanner strips newlines, so we need to add them back for cat
+ if _, err := dp.output.Write([]byte{'\n'}); err != nil {
+ return err
+ }
+ }
}
// Update transmission stats