-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
cat: Add the -n line numbering feature #24382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome to the project!
It doesn't really matter, but you can put the function in an anonymous namespace above the main to avoid having a declaration.
And also, it feels like output_buffer_with_line_numbers
can be written in a simpler way. Feel free to try something on that side, otherwise I will give it a shot on a future review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small nitpick, otherwise LGTM!
Please disregard the changes prior to this as it still does not contain the updates. Thank you for bearing with me. |
Adds the -n line numbering feature with the same formatting as gnu's cat function.
@@ -11,15 +11,36 @@ | |||
#include <LibCore/System.h> | |||
#include <LibMain/Main.h> | |||
|
|||
struct LineTracker { | |||
size_t line_count = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi: size_t line_count { 1 };
is what we use in most other places. I'll merge this, but if you end up touching this file again, maybe you could fix it up then.
Thanks! |
Adds the -n line numbering feature to cat, with the same formatting as gnu's cat function.