serenity icon indicating copy to clipboard operation
serenity copied to clipboard

cat: Add -b to number non-blank lines

Open ebanner opened this issue 1 year ago • 3 comments

This PR adds a -b option to the cat command to number non-blank lines:

image

This is one of two implementations I came up with. It most closely follows the approach of the existing implementation, where we set the flag whether we need to print out a line number at the end of the for loop then check the flag at the beginning of the next iteration for loop.

The other approach diverges fro this approach and opts for a state machine-based approach https://github.com/SerenityOS/serenity/pull/24918

I personally think this approach is more difficult to understand than the other state machine-based approach.

ebanner avatar Aug 09 '24 14:08 ebanner

Hello!

One or more of the commit messages in this PR do not match the SerenityOS code submission policy, please check the lint_commits CI job for more details on which commits were flagged and why. Please do not close this PR and open another, instead modify your commit message(s) with git commit --amend and force push those changes to update this PR.

BuggieBot avatar Aug 09 '24 14:08 BuggieBot

@PerrinJS also tagging you over here 🙂

ebanner avatar Aug 12 '24 13:08 ebanner

Tagging you over here @nico as well https://github.com/SerenityOS/serenity/pull/24918#issuecomment-2296557197

ebanner avatar Aug 19 '24 13:08 ebanner

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

stale[bot] avatar Sep 18 '24 04:09 stale[bot]

This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions!

stale[bot] avatar Oct 05 '24 18:10 stale[bot]