cat: add -A flag (equivalent to GNU cat -A)#357
Merged
Conversation
Add -A flag to cat(1) utility, which is equivalent to -et (enables vflag, eflag, and tflag). This matches the behavior of GNU cat. Updated man page and added a new ATF test case to verify equivalence. AI-Assisted-by: Gemini CLI <noreply@google.com>
Reviewer's GuideAdds a new -A flag to cat(1) that behaves like GNU cat -A by enabling the existing -e and -t behaviors (vflag, eflag, tflag), documents it in the man page, and introduces an ATF test to verify equivalence with -et. Flow diagram for cat -A flag behaviorflowchart LR
User["User runs: cat -A file"] --> CatMain["main(argc, argv)"]
CatMain --> Getopt["getopt(SUPPORTED_FLAGS)"]
Getopt -->|'-A'| SetFlags["eflag = 1\ntflag = 1\nvflag = 1"]
SetFlags --> Display["display_file() uses eflag, tflag, vflag"]
Display --> Output["Output with non-printing chars, $ at EOL, ^I for tabs"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In bin/cat/tests/Makefile you add A_flag_test to ATF_TESTS_SH while the existing tests use NETBSD_ATF_TESTS_SH, so consider using the same variable to ensure the new test is discovered and run consistently with the rest.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In bin/cat/tests/Makefile you add A_flag_test to ATF_TESTS_SH while the existing tests use NETBSD_ATF_TESTS_SH, so consider using the same variable to ensure the new test is discovered and run consistently with the rest.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request implements the -A flag for the cat utility, which is equivalent to the -et options. The changes include updates to the command-line argument parsing, the manual page, and the addition of a new test case. The review feedback identifies a grammatical regression in the manual page and an omission in the usage() function, which needs to be updated to include the new flag.
| .Op Ar | ||
| .Sh DESCRIPTION | ||
| The | ||
| .Nm |
Comment on lines
+179
to
+181
| case 'A': | ||
| eflag = tflag = vflag = 1; | ||
| break; |
laffer1
added a commit
that referenced
this pull request
May 21, 2026
Add -A flag to cat(1) utility, which is equivalent to -et (enables vflag, eflag, and tflag). This matches the behavior of GNU cat. Updated man page and added a new ATF test case to verify equivalence. AI-Assisted-by: Gemini CLI <noreply@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add -A flag to cat(1) utility, which is equivalent to -et (enables vflag, eflag, and tflag). This matches the behavior of GNU cat.
Updated man page and added a new ATF test case to verify equivalence.
AI-Assisted-by: Gemini CLI noreply@google.com
Summary by Sourcery
Add a new -A option to the cat(1) utility and verify its behavior with documentation and tests.
New Features:
Documentation:
Tests: