Skip to content
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

lscpu: Ensure regex behaves correctly with multi-line input #219

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

alxndrv
Copy link
Contributor

@alxndrv alxndrv commented Feb 12, 2025

Noticed that the Model name was not getting picked up on my machine while working on lscpu. Seems like this is caused by the usage of ^and $ on a multi-line input (the contents of /proc/cpuinfo).

A quick and dirty fix is to just replace the start-of-line and end-of-line characters with \n.
Alternatively, we can make use of multi-line mode on the Regex itself: https://docs.rs/regex/latest/regex/struct.RegexBuilder.html#method.multi_line

Output before:

Architecture: x86_64
CPU(s): 16

Output now:

Architecture: x86_64
CPU(s): 16
Model name: AMD Ryzen 7 7700X 8-Core Processor

@cakebaker
Copy link
Contributor

Using multi-line mode looks like the cleaner approach.

@alxndrv
Copy link
Contributor Author

alxndrv commented Feb 12, 2025

Using multi-line mode looks like the cleaner approach.

Sounds good, pushed a change to make it so. Having the builder in place might actually make my life easier a bit with some ideas I have for my other PR, so getting this in would be nice.

@cakebaker cakebaker merged commit c0ae6bf into uutils:main Feb 12, 2025
13 checks passed
@cakebaker
Copy link
Contributor

Thanks!

Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (adaf45f) to head (b6a4bfd).
Report is 5 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #219   +/-   ##
===========================
===========================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

2 participants