Skip to content

Conversation

@jadecuster
Copy link

@jadecuster jadecuster commented Sep 20, 2025

This pull request was created to address Issue #1 cat which is addressing the lack of cat flags.

See /docs/catFlags.md for more documentation and test cases with expected outputs.

@jadecuster jadecuster closed this Sep 26, 2025
@jadecuster jadecuster reopened this Sep 26, 2025
@natyhl
Copy link

natyhl commented Oct 2, 2025

I’m reviewing this PR.

Copy link

@natyhl natyhl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All flags work how they are supposed to (tested on tester.txt), so the functionality delivered matches the original goals. The program successfully prints out when it A) can’t open a file that doesn’t exist, B) doesn’t recognize a flag name. Maybe just one suggestion I have is to add something like test_cat.sh, to not having to run tests manually. But otherwise good job on your project!

-t (display non-printing characters (see the -v option), and display tab characters as ‘^I’)
-s (squeeze multiple blank lines)
-v (show non-printing characters visibly)
--help (prints out what cat can do and what it's flags does)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like that the –help flag is included. The description is sufficient and makes the implementation of new flags more clear

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second half of the .md file is a little bit unorganized

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is clean and easy to read. Maybe I would include a description at the top of the file

@HenrikanHa
Copy link

I will code review this

@HenrikanHa
Copy link

HenrikanHa commented Oct 11, 2025

Verification
The goal of this PR is to add a fully-featured cat utility to xv6 with common flags (-n, -b, -e, -t, -s, -v) plus --help, supporting input from files and stdin. The implementation parses flags, prints usage, and processes characters as specified; a sample file is included. The first limitation is behavioral mismatches with GNU cat: -b does not override -n. Second is that running cat with no file or input does not show usage and waits indefinitely, which may confuse users.

Testing
The basic functionality of cat works correctly with files, stdin, and all supported flags. Most outputs match expected behavior.

  • Edge Case 1 Found: Empty lines are still numbered, even though -b (number non-empty lines) should override -n.
$ cat -b -n tester.txt
1	Hello world
2	
3		This line starts with a tab
4	This line has a DEL char: 
5	This line has a BEL char: 
6	
7	Another blank line follows:
8	
9	
10	End.
  • Edge Case 2 Found: cat with no file or input
$ cat 
tester.txt
tester.txt
adad
adad
fwefew
fwefew
fwe2r2
fwe2r2
efvcvc
efvcvc

The program enters an endless input loop and prints back whatever is typed. There is no usage message or exit. This may confuse users. Same behavior for cat with flag but no file

Code Walkthrough
The code is easy to read and each flag is handled in a clear way. The main logic for printing characters works correctly. The only issue in the logic is with the -b and -n flags used together. Right now, empty lines still get a number, even though -b is supposed to number only non-empty lines. There is no input handling when no file is provided (no usage message is shown, and the program waits for input forever). Other than that, the structure is solid and there are no major problems.

Formatting
The code is clean and consistently formatted. Indentation, spacing, and function structure are easy to follow. Variable names and comments are clear. No major formatting issues were found.

High Level Checks:

  • PR fully resolves the task/issue
  • Does the PR have tests? (No automated tests but manual testing is demonstrated)
  • Does the PR follow project code formatting standards?
  • Does the OS still compile and run?
  • Is documentation included? (Really detailed documentation but a little bit unorganized)

Code Checks:

  • Does the code achieve its intended purpose?
  • Were all edge cases considered?
  • Is the code organized and maintainable?
  • Does the code maintain the same level of performance? (no performance regressions)

@malensek
Copy link
Contributor

Nice work! This is looking great.

I am not a big fan of flag_n, flag_b... etc. for your option variables because we have no idea what they actually do.

You may want to add a note somewhere that -n overrides -b, I guess there you have to make a call one way or another.

Great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants